@carolioli wrote:
I am developing an application with Ionic and Angular, I make a post request that returns me a token of the Authorization header, until then I was able to get this value normally with the following code:
data.headers.get('Authorization')
The problem is that it only works when I run the application in the browser; when i try to run on android emulator, it returns null.
It is important to say that the request ends successfully, but the data does not return.
Full code:
logIn(username, password) { this.body = { 'username': username, 'password': password }; this.apiProvider.getToken(this.body, this.headers).subscribe( data=>{ this.storage.set('token', data.headers.get('Authorization')); this.navCtrl.setRoot(SideMenuPage); }, error=>{ console.log(error); this.msgError = true; } ); }
My config.xml:
<access origin="*" /> <allow-navigation href="http://api.pet.com.br/*" /> <allow-navigation href="https://api.pet.com.br/*" /> <allow-navigation href="data:*" /> <allow-intent href="http://api.pet.com.br/*" /> <allow-intent href="https://api.pet.com.br/*" /> <allow-intent href="http://*/*" /> <allow-intent href="https://*/*" /> <allow-intent href="http://*" /> <allow-intent href="https://*" /> <allow-intent href="tel:*" /> <allow-intent href="sms:*" /> <allow-intent href="mailto:*" /> <allow-intent href="geo:*" />
Posts: 1
Participants: 1