Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@request/api

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@request/api

Sugar API for @request/core consumers

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51K
increased by11.68%
Maintainers
2
Weekly downloads
 
Created
Source

@request/api

npm-version travis-ci coveralls-status

var api = require('@request/api')
var client = require('@request/client')

// API methods configuration
var config = {
  // HTTP methods
  method: {
    get: ['select']
  },
  // @request/core option methods
  option: {
    qs: ['where']
  },
  // custom methods
  custom: {
    request: ['fetch', 'snatch', 'submit']
  }
}

// custom methods implementation
var custom = {
  // pass any arguments to your custom methods
  request: function (callback) {
    if (callback) {
      // `this._options` contains the generated options object
      this._options.callback = callback
    }
    // the last method should return @request/core consumer
    return client(this._options)
    // return `this` if you want to chain further
  }
}

// initialize the API
var request = api(config, custom)

// GET http://localhost:6767?a=1
request
  .select('http://localhost:6767')
  .where({a: 1})
  .fetch((err, res, body) => {
    // request callback
  })

See @request/core for more details.

Keywords

FAQs

Package last updated on 12 Apr 2016

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