@hellosirandy/rest-api-wrapper
v2.0.2
Published
A simple rest api wrapper based on fetch
Maintainers
Readme
@hellosirandy/rest-api-wrapper
Install
$ npm install @hellosirandy/rest-api-wrapperUsage
Initialize
import API from '@hellosirandy/rest-api-wrapper';
const baseURL = 'https://example.com';
const api = API(baseURL);Get
const options = {
endpoint: '/test',
token: '123456-asdf', //option
params: {
foo: 'bar'
} //option
}
api.get(options)Post
const options = {
endpoint: '/test',
token: '123456-asdf', //option
body: {
foo: 'bar'
} //option
}
api.post(options)Put
const options = {
endpoint: '/test',
token: '123456-asdf', //option
body: {
foo: 'bar'
} //option
}
api.put(options)Delete
const options = {
endpoint: '/test',
token: '123456-asdf', //option
}
api.delete(options)