react-native - React Native 在 localhost 上请求 node.js api 时返回 [未处理的承诺拒绝:TypeError:网络请求失败]
问题描述
我正在使用我的 android 设备来运行应用程序。
我正在为此导入“react-native-axios”。
我尝试同时使用 10.0.2.2、192.168.1.77。没有什么对我有用。
const data = {
firstname: "abc",
lastname: "xyz"
email: "abc@gmail.com",
password:"123456"
}
axios.post(`http://192.168.1.77:3000/signup`, data)
.then(response=>{
console.log(response)
})
.catch(err=>{
console.log(err)
})
我在提出 Axios 请求时收到以下信息。
[Unhandled promise rejection: TypeError: Network request failed]
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:26416:19 in <unknown>
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:31004:20 in <unknown>
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:30920:8 in _callTimer
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:31128:8 in Object.callTimers
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3149:30 in MessageQueue.__callFunction
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2881:16 in <unknown>
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3103:12 in MessageQueue.__guard
* http://packager.zv-7nw.dhruvil18.frontend.exp.direct/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2880:13 in MessageQueue.callFunctionReturnFlushedQueue
* http://localhost:19001/debugger-ui/debuggerWorker.cff11639.js:4:901 in <unknown>