Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @ianwalter/requester with all npm packages installed. Try it out:

var requester = require("@ianwalter/requester")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@ianwalter/requester v2.4.2

A convenience wrapper around the Node.js http.request API

@ianwalter/requester

A convenience wrapper around the Node.js http.request API

npm page CI

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free