我在react native应用程序中使用以下fetch调用:
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);
});