环境
我正在使用 React Native 和 Expo 开发一个移动应用程序。
另外,在我的本地环境中使用 Laravel 开发 api。(http://localhost:8000/)
该应用程序正在世博客户端应用程序上运行。
我正在尝试做什么
我想从api获取数据。
代码
应用程序.js
componentDidMount() {
return fetch('http://localhost:8000/api/test')
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson);
})
.catch((error) => {
console.error(error);
});
}
Run Code Online (Sandbox Code Playgroud)
错误
类型错误:网络请求失败
世博版
3.22.3
如果您能给我任何建议,我将不胜感激。