HTTP problem


#1

hello guys, i have some trouble with ionic-native/http

import { HTTP } from '@ionic-native/http';

jsonTest(){
        var json_url = "http://next5.kz/json.php";
      
        this.http.get(json_url, {}, {}).then(data => {
            console.log(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);
        });
    }

i’m getting error

util.js:60 Native: tried calling HTTP.get, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

how can i fix it?

thanx


#2

How and where are you testing?


#3

You already post your answer. This plugin work only on native devices.

util.js:60 Native: tried calling HTTP.get, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator


#4

You don’t want native’s HTTP. You want Angular’s Http instead.