Async requests using ionic-native/http

Android has been locking down the security within chrome, making cross-origin requests far more complicated within cordova applications. As a result a good alternative to use is a native plugin such as the @ionic-native/http or cordova-plugin-advanced-http. Unfortunately, this gives you a method that is dependent upon callbacks rather than one that can be used asynchronously.

The good news is that you can fix this by wrapping the method in a promise as show below.

import {HTTP} from '@ionic-native/http'
const asyncHTTP = (url) => {
return new Promise((resolve, reject) => {
HTTP.get(url, {}, {},
(response) => { resolve(response.data); },
(response) => { reject(response.error); })
})
}