1.0.0 • Published 6 years ago

c247-api-wrapper v1.0.0

Weekly downloads
-
License
GPL-3.0
Repository
-
Last release
6 years ago

An easy way to send requests to an API using JSON Web Tokens. It auto saves the API's response.token as the next request's Authorization header.

Example

npm install --save c247-api-wrapper
import ApiWrapperService from 'c247-api-wrapper';

const apiWrapper = new ApiWrapperService();

// optionally, `apiWrapper.setAuthorizationToken('yourJWT')`. This isn't needed if you've already sent a request though

const dataToSend = {
    email: email,
    password: password
};

const response = apiWrapper.fetch('POST', 'https://api.example.com/login', dataToSend);

console.log(response); // { body: yourServerReponseJson, response: https://developer.mozilla.org/en-US/docs/Web/API/Response
1.0.0

6 years ago

1.0.1

6 years ago