Hello i am Trying to connect React-Native with Node.js using Fetch Api i tried many solutions i tried putting my IP address,localhost and 10.0.2.2 but nothing works i dont get any response back but when i change my code a little bit it gives me network failed request error.
React-Native Code:
//Sending Request to Node.js using Fetch API
await fetch("http://10.0.2.2:3000/studentSignup", {
//Setting Method
method:"POST",
//Setting Headers
headers:{
//Setting Content-Type
"Content-Type" : "application/json"
},
//Stringifying the email and password and storing it into body
body:JSON.stringify({
name,
gmail,
password,
retype
})
}).then(res=>{
console.log(res);
}).catch(err=>{
console.log(err);
});
Node.js:
const express = require("express");
const app = express();
app.use("/studentSignup", (req,res,next)=>{
console.log("ok");
});
app.listen(3000);