request-bin

1.0.3 • Public • Published

Request Bin Client

codecov Build Status npm version

Introduction

Request Bin is a pretty useful service (I've used it to test webhooks, for example) and it's API is relatively straight-forward, to boot!

Currently, there's a Request Bin client via the requestbin NPM package, however, it has a callback-based API while this client is Promise-based.

Installation

Install via the NPM package

npm install request-bin

API

createBin

  • Creates a bin and returns a Promise containing bin details
  • Takes an optional isPrivate parameter - the default value is false
import { RequestBinClient } from 'request-bin';
 
// Prints public bin details
RequestBinClient.createBin().then(binDetails => console.log(binDetails));
 
// Prints private bin details
RequestBinClient.createBin(true).then(binDetails => console.log(binDetails));

getBin(binId)

  • Returns a Promise containing bin details for a given binId
import { RequestBinClient } from 'request-bin';
 
const binId = 'someBinId';
 
// Prints bin's details
RequestBinClient.getBin(binId).then(binDetails => console.log(binDetails));

getRequests(binId)

  • Returns a Promise containing for HTTP request details for a specific bin
import { RequestBinClient } from 'request-bin';
 
const binId = 'someBinId';
 
// Prints bin's requests details
RequestBinClient.getRequests(binId).then(requestsDetails => console.log(requestsDetails));

getRequest(binId, requestId)

  • Returns a Promise containing details for a specific HTTP request made against a specific bin
import { RequestBinClient } from 'request-bin';
 
const binId = 'someBinId';
const requestId = 'someRequestId';
 
// Prints request details for a specific request in a bin
RequestBinClient.getRequest(binId, requestId).then(requestDetails => console.log(requestDetails));

Readme

Keywords

Package Sidebar

Install

npm i request-bin

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • jaebradley