I have an application that im uses fetch to authenticate a user. It worked until a few days ago, and I do not change anything. just updated from reaction 0.27 to 0.28, and not sampling does not work.
I searched for almost 2 days and I read almost all the questions on stackoverflow. most users try to extract something from localhost, and when they change it to the actual IP address, they make it work. but I didnβt get anything from localhost, my code was also used.
here is my code:
fetch('http://somesite.com/app/connect', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'language':'en-US', 'Authorization': 'Bearer ' + access_token, }, body: JSON.stringify({ uid: uid, refresh_token: refresh_token, token: access_token, device: device_id, device_name: device_name, }) }) .then((response) => response.json()) .then((responseData) => { console.log(JSON.stringify(responseData.body)) }) .catch((err)=> { console.log('Some errors occured'); console.log(err); }) .done();
I tried to make some new projects, just, just used a simple example of learning lessons, it gave the same error. I tried to open my site, which I am trying to connect to it, through a browser in the emulator, it works, but it seems that through my application I canβt connect to any website / ip. it gives this error in chrome console:
TypeError: Network request failed at XMLHttpRequest.xhr.onerror (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:28193:8) at XMLHttpRequest.dispatchEvent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:14591:15) at XMLHttpRequest.setReadyState (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29573:6) at XMLHttpRequest.__didCompleteResponse (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29431:6) at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:29506:52 at RCTDeviceEventEmitter.emit (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:13428:23) at MessageQueue.__callFunction (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11999:23) at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11906:8 at guard (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11857:1) at MessageQueue.callFunctionReturnFlushedQueue (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&hot=true:11905:1)
I actually have the same problem as this user here: An invalid React network request always fails
UPDATE: info.plist from xcode
Any help would be appreciated!
javascript ios fetch reactjs react-native
Ata Mohammadi Jun 28 '16 at 13:12 2016-06-28 13:12
source share