Piyush
Piyush

Reputation: 590

ionic cordova plugin add cordova-plugin-advanced-http already installed

I am new on Ionic Mobile application development, so I am trying to POST data from Ionic app. Whenever I have run the app in browser using

ionic cordova run browser

It display below issue in console,

Native: tried calling HTTP.post, but the HTTP plugin is not installed.

Install the HTTP plugin: 'ionic cordova plugin add cordova-plugin-advanced-http'.

I have installed same plugin using terminal but terminal give warnings as its already installed. enter image description here

Please Suggest.

Upvotes: 0

Views: 2641

Answers (4)

Nishant Tamilselvan
Nishant Tamilselvan

Reputation: 322

The Native Http plugin is the only way to handle the CORS from the client-side.

The way I see your problem, there might two possible fixes

  1. Check whether the plugin is called after the platform.ready().

  2. Even after it, if doesn't work or show the same error then follow this method.

    // Declare cordova as a global constant
    declare const cordova;
    
    // directly call the cordova pulgin using "cordova.pulgin.http"
    
    cordova.plugin.http.post(apiUrl, {}, {},
    response => {},
    response => {})
    

Upvotes: 0

user10196907
user10196907

Reputation:

I hade the same problem and I solve it with uninstall and reinstall the plugin

Uninstall plugin completely

ionic cordova plugin remove cordova-plugin-advanced-http
npm uninstall @ionic-native/http

and reinstall it

ionic cordova plugin add cordova-plugin-advanced-http
npm install @ionic-native/http

Upvotes: 0

Jaydeep Kataria
Jaydeep Kataria

Reputation: 867

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

Upvotes: 0

Reza
Reza

Reputation: 19933

Based on this https://ionicframework.com/docs/native/http/ you also need to run

npm install --save @ionic-native/http

and referencing it correctly in your app, please take a look at above link

Also for running app in browser try below command

Ionic serve

Upvotes: 1

Related Questions