Socket
Socket
Sign inDemoInstall

ajax-request

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ajax-request

Http request for nodejs, and it also support file download


Version published
Weekly downloads
24K
decreased by-0.68%
Maintainers
1
Weekly downloads
 
Created
Source

ajax-request — Simplified http request

NPM

var request = require('ajax-request');

install

npm install ajax-request --save

test

mocha

API

request(options, callback)

  • {obejct|string} options required
    If the options is string, it will send get request.
    • {string} options.url required
    • {string} options.method [options.method=GET]
      The http request type
    • {obejct} options.data
      if the request type is GET, it's appended to query string of the URL, or it's sended to remote of body.
    • {object} options.headers
      An object containing request headers.
    • {string} options.encoding
      Set response data encoding
    • {boolean} options.isBuffer [options.isBuffer=false]
      Parse response data to buffer
    • {boolean} options.json [options.json=false]
      Parse response data to json
  • {function} callback required
request('url', function(err, res, body) {});

request({
  url: '',
  method: 'GET',
  data: {
    query1: 'value1'
  }
}, function(err, res, body) {
  
});

.post(options, callback)

The API same as request

request.post({
  url: 'url',
  data: {},
  headers: {}
});

.download(options, callback)

  • {obejct} options required
    • options.url {string} required
    • options.ignore {boolean} [options.ignore=false]
      Is the filepath ignore case.
    • options.rootPath {string} [options.rootPath='']
      The root of dest path
    • options.destPath {string|function}
      Custom the download path.
  • {function} callback required
request.download({
  url: 'path/index.png',
  rootPath: ''
}, function(err, res, body, destpath) {});

request.download({
  url: 'path/index.png',
  destPath: function(filename) {
    return filename;
  }
}, function(err, res, body, destpath) { });

.base64(url, callback)

Deprecated, move to base64

Keywords

FAQs

Package last updated on 27 Jun 2017

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