suddenly-api

A simple API consumer that supports JSON Web Token auth

Usage no npm install needed!

<script type="module">
  import suddenlyApi from 'https://cdn.skypack.dev/suddenly-api';
</script>

README

Suddenly API Client

CircleCI

A simple API consumer that supports JSON Web Token auth.

Usage

The HTTP methods get, post, put, and delete are supported.

const API = require('suddenly-api');
const api = new API('https://example.com');


api.get('/things').then((things) => {
    console.log(things);
}).catch((err) => {
    console.log(err);
});


// Post and Put use a payload
api.post('/things', { name: 'New Thing' }).then((thing) => {
    console.log(thing);
}).catch((err) => {
    console.log(err);
});

Session objects can be set (token is expected if using JSON Web Tokens):

api.setSession({ token: 'encodedtokenstring' });