🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

a4-http

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a4-http

Angular 4 Enhanced Http Service

0.0.3
latest
Source
npm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

a4-http

Angular 4 Enhanced Http Service

How-To

Install

npm install a4-http

app.module.ts

  • Add HttpModule to imports of the app.module.ts.

...
import { HttpModule } from 'a4-http';
...

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...,
    HttpModule,
    ...
  ],
  ...
})

Inject the service

constructor(private http: HttpService) { }

Show/Hide the Spinner

this.http.setSpinner(
    () => {
        ... // show spinner code
    }, () => {
        ... // hide spinner code
    }
);

get, post, put, patch & delete

public get(url: string, showSpinner?: boolean): Observable<Response>;
public get(url: string, options?: any, showSpinner?: boolean): Observable<Response>;

public post(url: string, body: any, showSpinner?: boolean): Observable<Response>;
public post(url: string, body: any, options?: any, showSpinner?: boolean): Observable<Response>;

public put(url: string, body: any, showSpinner?: boolean): Observable<Response>;
public put(url: string, body: any, options?: any, showSpinner?: boolean): Observable<Response>;

public patch(url: string, body: any, showSpinner?: boolean): Observable<Response>;
public patch(url: string, body: any, options?: any, showSpinner?: boolean): Observable<Response>;

public delete(url: string, showSpinner?: boolean): Observable<Response>;
public delete(url: string, options?: any, showSpinner?: boolean): Observable<Response>;

redirect when error

this.http.setRedirect({
      '-1': '/error',
      0: '/signin',
      401: '/signin',
      403: '/signin'
    });
  • Redirect to /signin if http status is 0, 401 or 403.
  • '-1' is the default route if there is an error... '-1' is optional.

FAQs

Package last updated on 17 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts