@ianwalter/requester
v2.5.0
Published
A convenience wrapper around the Node.js http.request API
Downloads
21
Maintainers
Readme
@ianwalter/requester
A convenience wrapper around the Node.js http.request API
Installation
yarn add @ianwalter/requester
Usage
Simple example GET request:
const { requester } = require('@ianwalter/requester')
const response = await requester.get('http://example.com/api/v1/cats')
Example POST request with custom base options:
const { Requester } = require('@ianwalter/requester')
const requester = new Requester({ baseUrl: 'http://example.com/api' })
const response = await requester.post('/v1/cats', { name: 'Nibblet' })
Example GET request with a custom request header:
const { requester } = require('@ianwalter/requester')
const options = { headers: { authorization: 'Bearer abc123' } }
const response = await requester.get('http://example.com/api/v1/cats', options)
License
Hippocratic License - See LICENSE
Created by Ian Walter