Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 即使使用UseClearTextTraffic=true,也会对本机Axios网络错误()作出反应_React Native_Axios - Fatal编程技术网

React native 即使使用UseClearTextTraffic=true,也会对本机Axios网络错误()作出反应

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: {

自从一周前我试图在每次导致网络错误时对我的api进行Fetch或Axios调用以来,我就一直存在这个问题。我看到了一些关于的帖子,并试图将UseSlearTextTraffic=true添加到androidManifest.xml中,但问题仍然存在

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');
    });
};

当您的请求不正确时,也会发生网络错误。请检查您的请求,传递所需的标头和参数,然后重试。