我在 React Native 应用程序中使用以下获取调用:
fetch(apiUrls.signInUrl, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
user: {
email: username,
password: password,
}
})
})
.then(response => {
response.json().then(responseJson => {
dispatch(AccountActions.loginResponse(username, password, responseJson.token, response.status));
dispatch(CardActions.getCards(username, responseJson.token));
});
})
.catch(err => {
console.error(err);
});
最佳答案
在 IOS 中,默认情况下禁用 http 连接。所以你必须启用它。虽然不推荐,但对于 Debug模式应该没问题。
步骤如下: 1. 你在 Xcode 中进入你的 iOS 项目的 Info.plist 文件
祝你好运!
关于ios - 在 react native 应用程序中使用提取时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39303063/