Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

jaebradley/request-bin

Repository files navigation

Request Bin Client

codecov Build Status npm version

NPM

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));

Releases

No releases published

Packages

No packages published