React native 即使使用UseClearTextTraffic=true,也会对本机Axios网络错误()作出反应
自从一周前我试图在每次导致网络错误时对我的api进行Fetch或Axios调用以来,我就一直存在这个问题。我看到了一些关于的帖子,并试图将UseSlearTextTraffic=true添加到androidManifest.xml中,但问题仍然存在React native 即使使用UseClearTextTraffic=true,也会对本机Axios网络错误()作出反应,react-native,axios,React Native,Axios,自从一周前我试图在每次导致网络错误时对我的api进行Fetch或Axios调用以来,我就一直存在这个问题。我看到了一些关于的帖子,并试图将UseSlearTextTraffic=true添加到androidManifest.xml中,但问题仍然存在 export default () => { return axios.create({ baseURL: 'https//myApi', withCredentials: true, headers: {
export default () => {
return axios.create({
baseURL: 'https//myApi',
withCredentials: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Accept':'application/json',
'Content-Type':'application/json',
},
});
};
const FechtEmpresaById = async (id: number) => {
return Empresa()
.get('/')
.then((response: any) => {
console.log(response,"si funciona");
return response.data.data;
})
.catch((e) => {
console.log(e, 'ha ocurrido un error \n \n \n');
});
};
当您的请求不正确时,也会发生网络错误。请检查您的请求,传递所需的标头和参数,然后重试。