New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fetchagent

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetchagent

Flex API for global fetch

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
53
increased by278.57%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Build Status Dependency Status

fetchagent

Flex API for global fetch

Install

$ npm install --save fetchagent

Usage

var fa = require('fetchagent');


// using callbacks
fa
  .get('http://httpbin.org/xml')
  .end(function(err, response) {
    if (err) {
      console.log(err, status);
    }
    console.log("Received:", response);
  });

// using promises
fa
  .post('http://httpbin.org/post')
  .send({ echo: 42 })
  .json()
  .then(function(response) {
    console.log("Received:", response.echo);
  });

API

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

License

MIT © Damian Krzeminski

Keywords

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc