I am attempting to use @ionic-native/http on iOS and Web with no success. App starts on both platforms, but the plugin does not work.
I hope that covers the most important ones.
ionic start myApp tabsnpm install --save @capacitor/cli @capacitor/corenpm run build --prodnpx cap init <name> <id>npx cap add iosnpx cap copynpx cap open ios
npm install cordova-plugin-advanced-httpnpm install @ionic-native/httpnpx cap syncAccording to the documentation (which I might have misunderstood) that should be it.
When attempting to call an API:
Native: tried calling HTTP.get, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
I know I don't use Cordova per se but shouldn't it be covered by npx cap sync?
[error] - ERROR {"line":38,"column":38,"sourceURL":"capacitor://localhost/tab2-tab2-module.js"}
I was lucky to finally find some more information.
I am not really sure why, but this additional plugin helped https://github.com/sneas/ionic-native-http-connection-backend. Requests can be made through HttpClient and they use Cordova plugin so that they bypass proxy.
Capacitor won't work on the browser according to https://github.com/ionic-team/capacitor/issues/767#issuecomment-415481452
So my assumption that it will was wrong. Previously mentioned plugin will delegate requests through HttpClient so it is nice workaround for the browser, although won't fix CORS issue.
CORS issue at this point can be handled by a proxy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With