我使用Axios在我的本地应用程序上发出http请求,但是当我将版本58更新到59时,网络仅在android中不起作用。
我需要帮助了解这是版本错误还是其他我弄错的东西:
代码示例:
const URL = 'http://XXX.XXX.XXX.XXX:8000/api/auth';
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.headers.post['Accept'] = 'application/json';
export const tryLogin = ({ email, password, navigation }) => async dispatch => {
try {
let response = await axios.post(URL, {login: email, password: password});
if(response.status == 200) {
await AsyncStorage.setItem('token', `Bearer ${response.data.token.accessToken}`);
dispatch({type: USER_LOGIN_SUCCESS, token: response.data.token.accessToken});
navigation.replace('drawerNavigator');
} else {
Toast.show({
text:'Email ou senha inválidos outros status',
duration: 3000
});
console.log(response);
}
} catch(e) {
console.log(e);
Toast.show({
text: 'Usuário ou senha inválidos',
duration: 3000
});
}
}
感谢您的帮助。