fetch() res.status says "0", but it is actually "200"
Reported by
trusktr@gmail.com,
Jun 2 2017
|
||
Issue description
UserAgent: Mozilla/5.0 (X11; CrOS x86_64 9334.69.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.112 Safari/537.36
Steps to reproduce the problem:
1. Set up a device on the network, then for example:
2. fetch('http://192.168.0.8', {mode: 'no-cors'}).then(function(res) { console.log(res.status) })
3. It says "0", but Network tab shows 200.
What is the expected behavior?
I expect it to be 200, and I want the following to work:
fetch('http://192.168.0.8', {mode: 'no-cors'})
.then(r => r.text())
.then(t => console.log(t))
What went wrong?
But it doesn't work because status is 0, and the text is blank (but network tab shows response the text just fine).
Did this work before? N/A
Does this work in other browsers? N/A
Chrome version: 58.0.3029.112 Channel: n/a
OS Version: 9334.69.0
Flash Version: Shockwave Flash 25.0 r0
Is this a bug? Or does using `no-cors` cause this to happen?
If 'no-cors' is the reason, then how do I make it work?
If I run `curl`, I can verify the endpoint works fine:
> curl http://192.168.0.8
[2123,8923,239]
(That's from an device sending accelerometer data)
,
Jun 2 2017
,
Jun 2 2017
Here's screenshots of what's happening.
,
Jun 2 2017
What I'm trying to do is get accelerometer data from an espruino, and both espruino and computer are on the same local network. As a workaround, since the computer is running a server (Meteor), I can have the client communicate to the server and server to espruino, and all the way back to the client, but that doubles the number of network requests.
,
Jun 5 2017
This is working as intended. no-cors is for loading certain resources (scripts, images, etc) without CORS. JS developers cannot access its contents. Please see https://fetch.spec.whatwg.org/#concept-filtered-response-opaque for details. |
||
►
Sign in to add a comment |
||
Comment 1 by trusktr@gmail.com
, Jun 2 2017