Issue
i am new to react native and i am trying to submit a api using axios in react native but i am getiign [AxiosError: Network Error] i dont know what this is or how i can fix this
function getdata() {
const Data = {
babyname: babyname,
password: name,
email: email,
phone: nuber,
period: mydate,
};
console.log(Data);
axios({
method: 'POST',
url: 'http://127.0.0.1:8000/api/details/',
data: Data,
})
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
i used the default inspect elemt in react native and have network tab opened
Solution
I think the problem is from Ip that you are trying to get connected
it seems that you are using an android emulator, so 127.0.0.1 is not the IP that runs in Postman
if 127.0.0.1 is your localhost, changing that to 10.0.2.2 might fix your problem
axios({
method: 'POST',
url: 'http://10.0.2.2:8000/api/details/',
data: Data,
})
Answered By - Ali Sattarzadeh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.