@suddenly/api
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@suddenly-api

A helper for making API calls.

Usage

import API, { queryString } from '@suddenly/api';

const api = new API('app-name', '/api');

api.setSessionToken('SOME SIGNED JWT TOKEN TO AUTH WITH YOUR SERVER');

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

// /things?search=something
api.get('/things' + queryString({ search: 'Something' })).then(things => {
  console.log('things that match Something:', things);
});

api.post('/things', { name: 'New Thing' }).then(thing => {
  console.log(thing);
});

api.put('/things/1', { name: 'Updated Thing' }).then(thing => {
  console.log(thing);
});

api.delete('/things/1').then(thing => {
  console.log(thing);
});

Contributors

Readme

Keywords

Package Sidebar

Install

npm i @suddenly/api

Weekly Downloads

1

Version

1.2.0

License

ISC

Unpacked Size

11.1 kB

Total Files

7

Last publish

Collaborators

  • nathanhoad