I am using Expo Client for development and I am not able to send a login API call.
onSubmit fuction
const onSubmit = async (username, password)=>{
console.log(username);
console.log(password);
await axios.post(
'https://backend.unknownchats.com/accounts/login/',
{
username: username,
password: password,
},
{
headers: {
'Content-Type': "application/json",
'Accept': "application/json",
}
}
).then(res=>{
console.log(res.data);
if (res.data.status==="success"){
localStorage.setItem('username',res.data.username);
localStorage.setItem('token',res.data.token);
navigation.navigate('Settings');
}else{
setError(res.data.error);
}
}).catch(err=>console.log(err));
}
Take a look at the attached error code.
sumit 97127516
Network Error
at node_modules\axios\lib\core\createError.js:17:22 in createError
at node_modules\axios\lib\adapters\xhr.js:120:6 in handleError
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:609:10 in setReadyState
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:396:6 in __didCompleteResponse
at node_modules\react-native\Libraries\vendor\emitter\_EventEmitter.js:135:10 in EventEmitter#emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:414:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:365:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:4 in callFunctionReturnFlushedQueue