payload: {"action":"created","issue":{"url":"https://api.github.com/repos/axios/axios/issues/973","repository_url":"https://api.github.com/repos/axios/axios","labels_url":"https://api.github.com/repos/axios/axios/issues/973/labels{/name}","comments_url":"https://api.github.com/repos/axios/axios/issues/973/comments","events_url":"https://api.github.com/repos/axios/axios/issues/973/events","html_url":"https://github.com/axios/axios/issues/973","id":238371523,"node_id":"MDU6SXNzdWUyMzgzNzE1MjM=","number":973,"title":"Axios doesn't work with Android (emulator) raising a Network Error","user":{"login":"Donovantxy","id":6199235,"node_id":"MDQ6VXNlcjYxOTkyMzU=","avatar_url":"https://avatars1.githubusercontent.com/u/6199235?v=4","gravatar_id":"","url":"https://api.github.com/users/Donovantxy","html_url":"https://github.com/Donovantxy","followers_url":"https://api.github.com/users/Donovantxy/followers","following_url":"https://api.github.com/users/Donovantxy/following{/other_user}","gists_url":"https://api.github.com/users/Donovantxy/gists{/gist_id}","starred_url":"https://api.github.com/users/Donovantxy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Donovantxy/subscriptions","organizations_url":"https://api.github.com/users/Donovantxy/orgs","repos_url":"https://api.github.com/users/Donovantxy/repos","events_url":"https://api.github.com/users/Donovantxy/events{/privacy}","received_events_url":"https://api.github.com/users/Donovantxy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":42,"created_at":"2017-06-25T09:59:49Z","updated_at":"2019-08-24T08:48:26Z","closed_at":null,"author_association":"NONE","body":"I'n new with React Native, and I was playing around with components and http ajax request, and all went fine with iOs emulator, until I thought to test on Android emulator.\r\n\r\nThis is my Http class:\r\n\r\n```\r\nimport 'url-search-params-polyfill';\r\nimport axios from 'axios';\r\nimport { AsyncStorage } from 'react-native';\r\nimport Rx from 'rxjs/Rx';\r\n\r\nlet _HttpServiceInstance = null;\r\n\r\nclass HttpService {\r\n\r\n  constructor(envStr) {\r\n    console.log('DEFAULT', axios.defaults);\r\n    if(!_HttpServiceInstance){\r\n      this.__proto__.ghtnk = null;\r\n      axios.defaults.baseURL = this.getBaseUrlApi()[envStr || 'DEV'];\r\n      axios.interceptors.response.use(\r\n        (resp) => {\r\n          let ghresp = resp.data || resp;\r\n          ghresp.status = resp.data ? resp.data.status : resp.status;\r\n          return ghresp;\r\n        },\r\n        (err) => {\r\n          if( err.status === 401 ){\r\n              this.removeToken();\r\n              // go to login\r\n          }\r\n          return Promise.reject(err);\r\n        }\r\n      )\r\n      _HttpServiceInstance = this;\r\n    }\r\n    return _HttpServiceInstance;\r\n  }\r\n\r\n  getBaseUrlApi = () => {\r\n    return {\r\n      DEV : 'https://dev-api.domainname.com/',\r\n      TEST: 'https://test-api.domainname.com/',\r\n      QA  : 'https://qa-api.domainname.com/',\r\n      LIVE: 'https://api.domainname.com/',\r\n    };\r\n  }\r\n\r\n  switchBaseUrlApi(envStr) {\r\n    axios.defaults.baseURL = this.getBaseUrlApi()[envStr];\r\n  }\r\n\r\n  getToken = (callback) => {\r\n      let promise = AsyncStorage.getItem('ghtkn');\r\n      if( callback ){\r\n        promise.then(callback, () => { console.log('getToken: ', err) });\r\n      }\r\n      else return promise;\r\n  };\r\n\r\n  setToken = (token) => {\r\n    return AsyncStorage.setItem('ghtkn', token);\r\n  };\r\n\r\n  removeToken = () => {\r\n    AsyncStorage.removeItem('ghtkn');\r\n  };\r\n\r\n  setAuthHeaders = (callback, noNeedToken) => {\r\n    if ( noNeedToken ) {\r\n      callback(); return;\r\n    }\r\n    this.getToken(\r\n      (token) => {\r\n        if (token) {\r\n          axios.defaults.headers.common['Authorization'] = 'Bearer ' + token;\r\n          callback();\r\n        }\r\n        else{ console.log('NO TOKEN PRESENT'); }\r\n      },\r\n      (err) => { console.log('GET TOKEN: ', err); },\r\n    );\r\n  };\r\n\r\n  // GET\r\n  get = (url) => {\r\n    let subject = new Rx.Subject();\r\n    this.setAuthHeaders((token) => {\r\n      axios.get(url).then(\r\n        (data) => { subject.next(data); },\r\n        (err) => { console.log('GET: ', err); }\r\n      );\r\n    });\r\n    return subject;\r\n  };\r\n\r\n  // POST\r\n  post = (url, payload, noNeedToken) => {\r\n    let subject = new Rx.Subject();\r\n    this.setAuthHeaders(() => {\r\n      axios.post( url, this.setParams(payload)).then(\r\n        (resp) => { subject.next(resp); },\r\n        (err) => {\r\n          console.log('POST ERROR');\r\n          console.log(err.request, Object.keys(err) );\r\n          subject.error(err);\r\n        }\r\n      );\r\n    }, noNeedToken);\r\n    return subject;\r\n  };\r\n\r\n  // PUT\r\n  put = (url, payload) => {\r\n    let subject = new Rx.Subject();\r\n    this.setAuthHeaders((token) => {\r\n      axios.put( url, this.setParams(payload)).then(\r\n        (resp) => { subject.next(resp); },\r\n        (err) => { console.log('PUT: ', err); }\r\n      );\r\n    });\r\n    return subject;\r\n  };\r\n\r\n  // LOGIN\r\n  login = (user, pw) => {\r\n    return this.post('user/authentication', {username: user, password: pw}, true)\r\n               .do((resp) => { this.setToken(resp.token); })\r\n  };\r\n\r\n  setParams = (jsonParams) => {\r\n    let params = new URLSearchParams();\r\n    for(param in jsonParams){\r\n      if( jsonParams.hasOwnProperty(param) ){\r\n        params.append(param, jsonParams[param]);\r\n      }\r\n    }\r\n    return params;\r\n  };\r\n\r\n}\r\n\r\nexport { HttpService };\r\n```\r\n\r\nThis is the error I'm getting from the post request, using **login()** function I created using **axios.post()**\r\n\r\n![screen shot 2017-06-24 at 22 32 54](https://user-images.githubusercontent.com/6199235/27515013-e266ee1c-5991-11e7-941c-0569390d3b16.png)\r\n\r\n## NOTE:\r\n\r\n- I'm using the latest version of Axios **^0.16.2**\r\n\r\n- My AndroidManifest.xml contains:\r\n```\r\n<uses-permission android:name=\"android.permission.INTERNET\" />\r\n<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />\r\n<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/>\r\n```\r\n- The APIs are under VPN, as I wrote all works fine with iOs emulator but doesn't with the Android one.\r\n"},"comment":{"url":"https://api.github.com/repos/axios/axios/issues/comments/524533371","html_url":"https://github.com/axios/axios/issues/973#issuecomment-524533371","issue_url":"https://api.github.com/repos/axios/axios/issues/973","id":524533371,"node_id":"MDEyOklzc3VlQ29tbWVudDUyNDUzMzM3MQ==","user":{"login":"helloitsm3","id":13825491,"node_id":"MDQ6VXNlcjEzODI1NDkx","avatar_url":"https://avatars3.githubusercontent.com/u/13825491?v=4","gravatar_id":"","url":"https://api.github.com/users/helloitsm3","html_url":"https://github.com/helloitsm3","followers_url":"https://api.github.com/users/helloitsm3/followers","following_url":"https://api.github.com/users/helloitsm3/following{/other_user}","gists_url":"https://api.github.com/users/helloitsm3/gists{/gist_id}","starred_url":"https://api.github.com/users/helloitsm3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helloitsm3/subscriptions","organizations_url":"https://api.github.com/users/helloitsm3/orgs","repos_url":"https://api.github.com/users/helloitsm3/repos","events_url":"https://api.github.com/users/helloitsm3/events{/privacy}","received_events_url":"https://api.github.com/users/helloitsm3/received_events","type":"User","site_admin":false},"created_at":"2019-08-24T08:48:26Z","updated_at":"2019-08-24T08:48:26Z","author_association":"NONE","body":"What is the error?"}}
other: {"actor":{"display_login":"helloitsm3"}}