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 400,000 packages pre-installed, including fetchagent with all npm packages installed. Try it out:

var fetchagent = require("fetchagent")

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

fetchagent v2.0.0

Flex API for global fetch

NPM version Build Status Dependency Status Dev Dependency Status


Flex API for global fetch


$ npm install --save fetchagent


var fa = require('fetchagent');

// using callbacks
  .end(function(err, response) {
    if (err) {
      console.log(err, status);
    console.log("Received:", response);

// using promises
  .send({ echo: 42 })
  .then(function(response) {
    console.log("Received:", response.echo);


To configure request use one or more:

  • get(url), put(url), post(url), delete(url) - HTTP method to url
  • query() - sets search params (a.k.a querystring)
  • set(name, vale) - sets header name to value
  • set(obj) - sets headers for all properties of the object
  • redirect(flag) - pass truthy value if fetchagent is supposed to automatically handle redirects

To send request use on of:

  • end(callback) - pass callback(err, body)
  • end() - returns a Promise that resolves to a response
  • json() - returns a Promise resolving to a parsed object
  • text() - returns a Promise resolving to a body text


MIT © Damian Krzeminski


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