Issue 1:
it is not working in android (react native app)

Issue 2:
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.

This is my Http class:

import 'url-search-params-polyfill';
import axios from 'axios';
import { AsyncStorage } from 'react-native';
import Rx from 'rxjs/Rx';

let _HttpServiceInstance = null;

class HttpService {

constructor(envStr) {
console.log('DEFAULT', axios.defaults);
if(!_HttpServiceInstance){
this.__proto__.ghtnk = null;
axios.defaults.baseURL = this.getBaseUrlApi()[envStr || 'DEV'];
axios.interceptors.response.use(
(resp) => {
let ghresp = resp.data || resp;
ghresp.status = resp.data ? resp.data.status : resp.status;
return ghresp;
},
(err) => {
if( err.status === 401 ){
this.removeToken();
// go to login
}
return Promise.reject(err);
}
)
_HttpServiceInstance = this;
}
return _HttpServiceInstance;
}

getBaseUrlApi = () => {
return {
DEV : 'https://dev-api.domainname.com/',
TEST: 'https://test-api.domainname.com/',
QA : 'https://qa-api.domainname.com/',
LIVE: 'https://api.domainname.com/',
};
}

switchBaseUrlApi(envStr) {
axios.defaults.baseURL = this.getBaseUrlApi()[envStr];
}

getToken = (callback) => {
let promise = AsyncStorage.getItem('ghtkn');
if( callback ){
promise.then(callback, () => { console.log('getToken: ', err) });
}
else return promise;
};

setToken = (token) => {
return AsyncStorage.setItem('ghtkn', token);
};

removeToken = () => {
AsyncStorage.removeItem('ghtkn');
};

setAuthHeaders = (callback, noNeedToken) => {
if ( noNeedToken ) {
callback(); return;
}
this.getToken(
(token) => {
if (token) {
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token;
callback();
}
else{ console.log('NO TOKEN PRESENT'); }
},
(err) => { console.log('GET TOKEN: ', err); },
);
};

// GET
get = (url) => {
let subject = new Rx.Subject();
this.setAuthHeaders((token) => {
axios.get(url).then(
(data) => { subject.next(data); },
(err) => { console.log('GET: ', err); }
);
});
return subject;
};

// POST
post = (url, payload, noNeedToken) => {
let subject = new Rx.Subject();
this.setAuthHeaders(() => {
axios.post( url, this.setParams(payload)).then(
(resp) => { subject.next(resp); },
(err) => {
console.log('POST ERROR');
console.log(err.request, Object.keys(err) );
subject.error(err);
}
);
}, noNeedToken);
return subject;
};

// PUT
put = (url, payload) => {
let subject = new Rx.Subject();
this.setAuthHeaders((token) => {
axios.put( url, this.setParams(payload)).then(
(resp) => { subject.next(resp); },
(err) => { console.log('PUT: ', err); }
);
});
return subject;
};

// LOGIN
login = (user, pw) => {
return this.post('user/authentication', {username: user, password: pw}, true)
.do((resp) => { this.setToken(resp.token); })
};

setParams = (jsonParams) => {
let params = new URLSearchParams();
for(param in jsonParams){
if( jsonParams.hasOwnProperty(param) ){
params.append(param, jsonParams[param]);
}
}
return params;
};

}

export { HttpService };

This is the error I'm getting from the post request, using login() function I created using axios.post()

NOTE:

I'm using the latest version of Axios ^0.16.2

My AndroidManifest.xml contains:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

The APIs are under VPN, as I wrote all works fine with iOs emulator but doesn't with the Android one.