rest-trankil.js

1.0.3 • Public • Published

rest-trankil.js

Usage

Init

import Rest from 'xeonys-rest-client'
import { store } from './store'

const headers = () => ({
  Authorization: `token ${store.getState().user.token}`,
  'Content-Type': 'application/json',
})

export new Rest(headers)

Need a fetch polyfill for IE, and babel-polyfill for every browsers.

GET

const res = await rest.get(url, useCustomHeader = true)

POST

const res = await rest.post(url, body, useCustomHeader = true)

PUT

const res = await rest.put(url, body, useCustomHeader = true)

PATCH

const res = await rest.patch(url, body, useCustomHeader = true)

Run and code

yarn && yarn start

Package Sidebar

Install

npm i rest-trankil.js

Weekly Downloads

2

Version

1.0.3

License

MIT

Last publish

Collaborators

  • didierfranc