Hello I am trying to make a request get with HTTP but it does not enter me in data.data tells me undefined, can you help me? Thank you!
It is entering the error.error
The api code is missing, I do not publish it.
import { IonicModule } from '@ionic/angular';
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Tab1Page } from './tab1.page';
import { HTTP } from '@ionic-native/http/ngx';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
RouterModule.forChild([{ path: '', component: Tab1Page }])
],
declarations: [Tab1Page]
})
export class Tab1PageModule {
constructor(private http: HTTP) {
this.http.get('http://api.openweathermap.org/data/2.5/forecast?zip=94040,us&appid=', {}, {})
.then(data => {
console.log(data.status);
console.log(data.data); // data received by server
console.log(data.headers);
})
.catch(error => {
console.log(error.status);
console.log(error.error); // error message as string
console.log(error.headers);
});
}
}
This is the error:
The json returns this to me: