Skip to content

HTTP wrapper for angular2 that includes basic Authentication Header via localStorage

Notifications You must be signed in to change notification settings

shiftEscape/http-local-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-local-auth

version downloads PRs Welcome MIT License

Installation

npm install --save http-local-auth

Usage

import { HttpLocalAuthService } from 'http-local-auth';

And inject the service to the constructor:

constructor (private HttpLocalAuth: HttpLocalAuthService) { ...

And you can use all request type provided: GET, POST, PATCH, PUT and DELETE

HttpLocalAuth.get('/path-to-api-endpoint-or-file').subscribe((successCallback) => {
    // do something
}, (errorCallback) => {
    // do something
});

Adding custom headers

HttpLocalAuth.addHeaders({<key>, <value>});

Note

By default, 'Accept': 'application/json' and 'Content-Type': 'application/json' headers are already added. Also, the Authorization header is being appended every request with a value from localStorage item token.

About

HTTP wrapper for angular2 that includes basic Authentication Header via localStorage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published