React-native: 'fetch' failed [version: 0.28.0-rc.0]

Created on 15 Jun 2016  路  18Comments  路  Source: facebook/react-native

Using 'fetch' to send request, it failed. Error message is 'Network request failed'. My code works well with '0.27'

Ran Commands Locked

Most helpful comment

I have resolved it by adding 'Allow Arbitrary Loads'
resolve

All 18 comments

I'm using RN0.28 and it works fine, both POST and GET method, so perhaps u missed something

Could you show me your code? I just run code from official site like this:

fetch('https://mywebsite.com/endpoint/', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    firstParam: 'yourValue',
    secondParam: 'yourOtherValue',
  })
})

My project was upgrade from "0.24''

'Image' can not send request too, it runs into "onLoadEnd"

'Image' can not display, here is my code: <Image source={{height:200,width:300,uri: 'http://facebook.github.io/origami/public/images/blog-hero.jpg'}}/>

I have resolved it by adding 'Allow Arbitrary Loads'
resolve

I'll close this issue as it has been resolved with _Allow Arbitrary Loads_, if not feel free to let me know.

@facebook-github-bot close

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

This solution worked for me too. Shouldn't react-native init and react-native upgrade be updated to set this flag?

I am getting this error while uploading video file using 0.27, I can upload a video up to-3-4 seconds, but when I try it something longer I get this error. Any idea?

In case anyone is wondering where you add Allow Arbitrary Loads:

Props to @12d

screen shot 2016-07-21 at 8 07 44 pm

Go down to App Transport Security Settings > hit the + button > select Allow Arbitrary Loads > change the bool value to YES

Keep in mind this might be a security risk for you and your users to allow non-secure connections... https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

Still getting the issue with RN version 0.45

Jun 27 16:23:36 Administrators-Mac-mini Experiments[38809] : { [TypeError: Network request failed]
line: 15459,
column: 29,
sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false' }

screen shot 2017-06-27 at 4 24 03 pm

Still having this issue even after adding 'Allow Arbitrary Loads', exception domains.
react-native: 0.50.4

@hazeeb Have you solved the issue.

@GopiKrishna10 Not yet. :(

Also having the issue, but only in debug build on iOS. That problem doesn't occur on a release build for me.

Still having this issue, have followed all suggested steps.

Was this page helpful?
0 / 5 - 0 ratings