【发布时间】:2017-02-02 12:36:42
【问题描述】:
我似乎无法在 Android 上获得以下 fetch 调用。它没有击中服务器,似乎也没有抛出任何错误。相同的代码适用于 iOS。我是否必须做一些特别的事情才能在 React Native 上启用 Android 的网络请求?提前致谢。
export const login = function(user, success, error) {
let path='http://localhost:3000/api/session';
fetch(path, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({user: user})
}).then((response) => {
return response.json();
}).then(success).catch(error);
};
【问题讨论】:
-
我也有同样的问题。您是如何使用此 API 的?
标签: android ios reactjs react-native