1.0.0 • Published 6 years ago
c247-api-wrapper v1.0.0
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