[英]AxiosError: Network Error in React Native on making api request to local backend
Frontend
await axios.get("http://localhost:8000/admin/api/getcategories",{
"Content-Type": "application/json",
}).then(result=>{
console.log(result);
}).catch(err=>{
console.log(err);
})
Backend
const cors = require('cors'); const cors = require('cors');
app.use(cors());
Tried restarting the application, and with other api tried sending without headers, but nothing worked, also added尝试重新启动应用程序,并与其他 api 一起尝试不带标头发送,但没有任何效果,还添加了
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
for android and NSAllowsArbitraryLoads for IOS对于 android 和 NSAllowsArbitraryLoads 对于 IOS
Try to use ngrok ( https://ngrok.com/ ) to make your local API public.尝试使用 ngrok ( https://ngrok.com/ ) 公开你的本地 API。 It is free for developers
对开发者免费
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.