Tried calling HTTP.post, but the HTTP plugin is not installed


#1

I’m trying to do a rather simple HTTP post with some JSON data on my Android device using the native HTTP plugin but I’m getting the following error:

pages/test-network/test-network.ts

import { HTTP } from '@ionic-native/http';
import { Component } from '@angular/core';
import { NavController, NavParams, IonicPage } from 'ionic-angular';
import { Hotspot } from '@ionic-native/hotspot';

@IonicPage()
@Component({
  selector: 'page-test-network',
  templateUrl: 'test-network.html',
})
export class TestNetworkPage {

  constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public Hotspot: Hotspot,
    public http: HTTP) {
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad TestNetworkPage');
  }

  ...snip...

  postLanmap(url: string, lanmap: any) {
    this.http.post(url, lanmap, {})
      .then(response => {
        console.log("test-network: got response: " + response);
      }).catch(err => {
        console.log("test-network: got error: " + err);
      });

    this.navCtrl.push('CurrentNetworkPage', {});
  }
}

error

Native: tried calling HTTP.post, but the HTTP plugin is not installed.
Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'

Here’s a confirmation that the plugin is indeed installed:

daniel:~/hl-mobile$ ionic cordova plugin add cordova-plugin-advanced-http
> cordova plugin add cordova-plugin-advanced-http --save
✔ Running command - done!
Plugin "cordova-plugin-advanced-http" already installed on android.
Adding cordova-plugin-advanced-http to package.json
Saved plugin info for "cordova-plugin-advanced-http" to config.xml

daniel:~/hl-mobile$ sudo npm install --save @ionic-native/http
+ @ionic-native/http@4.2.1
updated 1 package in 7.349s

Any idea what’s going on?


#2

See https://github.com/ionic-team/ionic-native/issues/1975

The issue appears to have been fixed but there might be a lag in updating npm


#3

Yup, that seems to fix it! Weird that I didn’t stumble across that Googling. Thanks!


#4

Hello
Has thsi been fixed.
I’m still getting the error
Ta
JC