Giter Club home page Giter Club logo

ionic-native-http-angular-wrapper's Introduction

Ionic Native Http Angular Wrapper

This is a basic package for wrapping the @ionic-native/http plugin@^4.3.0 with observables and providing a fallback to the @angular/common/http method.

This will only handle basic requests, anything more advanced you should use the packages separately.

This works with the WKWebView for iOS, and bypasses the CORS issues associated with @angular/common/http and WKWebView

Notes:

  • PATCH method is not available
  • Local files will have to be handled manually, use isNativeHttpAvailable() to check if nativeHttp will be used

For older versions of Ionic where @angular<5.0 is used, please use version 1.0.0.

Add native http client to Ionic project & add module

$ ionic cordova plugin add cordova-plugin-advanced-http
$ npm install ionic-native-http-angular-wrapper --save
# or yarn add ionic-native-http-angular-wrapper

Add to App Module - app.module.ts

// Import your module
import {NativeHttpWrapper} from 'ionic-native-http-angular-wrapper';
 
@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    IonicModule.forRoot(MyApp),
   //Put here
   NativeHttpWrapper
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
  ]
})
export class AppModule {}

Using the module

import {HttpWrapper} from "ionic-native-http-angular-wrapper";
  
constructor(private httpWrapper: HttpWrapper) {}
 
    public getStuff() {
        this.httpWrapper.get('http://google.co.uk', {},{})
    }
    
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.