【发布时间】:2021-09-04 15:09:10
【问题描述】:
我是 React Native 的新手,我正在尝试将 axios 请求发送到我的后端,但我被困在其中。
export const login = (email, password) => async dispatch => {
const config = {
headers: {
'Content-Type': 'application/json'
}
};
const body = JSON.stringify({ email, password });
const res = await axios.post(`http://localhost:8000/auth/jwt/create/`, body, config);
console.log('kk');
dispatch({
type: LOGIN_SUCCESS,
payload: res.data
});
dispatch(load_user());
};
虽然我已经在 React JS 中尝试过这个并且它运行良好。 请帮助我在 react native 中解决这个问题
【问题讨论】:
标签: react-native axios