Reputation: 340
I try to fetch data from an external server using fetsh() in React Native. My query looks like this:
fetch('https://xxx.xx/login.php', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: email,
password: password
})
}).then((response) => response.json())
.then((responseJson) => {
if(responseJson === 'Data Matched'){
this.props.navigation.navigate('Second', { Email: email});
}else{
Alert.alert(responseJson);
}
}).catch((error) => {
console.error(error);
return error;
});
during the execution on my Android Device I get the following error:
Network request failed
Stack trace:
node_modules\whatwg-fetch\dist\fetch.umd.js:505:17 in setTimeout$argument_0
node_modules\react-native\Libraries\Core\Timers\JSTimers.js:135:14 in _callTimer
node_modules\react-native\Libraries\Core\Timers\JSTimers.js:387:16 in callTimers
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:425:19 in __callFunction
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:6 in __guard$argument_0
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:373:10 in __guard
node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:4 in callFunctionReturnFlushedQueue
[native code]:null in callFunctionReturnFlushedQueue
...
When I open the file in the browser, everything works without problems.
I am glad about your help. Thanks a lot in advance. Lukas
Upvotes: 1
Views: 4250
Reputation: 340
after a long search I have now found the solution. Through a test on https://www.ssllabs.com/ssltest of my certificate I have received the following message:
This server's certificate chain is incomplete. Grade capped to B.
I uploaded my Certificate to https://certificatechain.io/ and added the .crt file to my SSL Configuration on my webserver. Now all works fine for me.
Hope I can help you with this.
Upvotes: 2