I'm looking to convert this request, which is using angular/http, so that I can get results on a physical device:
import { Http } from '@angular/http'; //old way
import { HTTP } from '@ionic-native/http'; //new way
The angular/http request
function getWeather() {
return this.http.get(this.url + '/' + latitude + ',' + longitude)
.map(res => res.json());
}
The method that is making the call, using 'subscribe'
this.weatherProvider.getWeather(latitude, longitude).subscribe(results => {
console.log(results);
});
I am wanting to convert this to native/http, available as a plugin in Ionic
It might look something like this:
function getWeather() {
return this.httpNative.get(this.url + '/' + latitude + ',' + longitude, {}, {})
.then(data => {
console.log(data.data);
})
.catch(error => {
console.log(error.error);
});
}
However, I am having some issues receiving the data in this method, as I can no longer subscribe to the result and it is not being mapped... I receive null results
this.weatherProvider.getWeather(latitude, longitude).subscribe(results => {
console.log(results);
});