npm

plato-request

0.1.4 • Public • Published

PLATO-REQUEST

🚦 A Request Library based on the Fetch API

Travis Coveralls dependencies devDependency Status NPM version

Change Log

0.1.0

  • support a mutate that return a none-promise value

Usage

basic

import request from 'plato-request'

request({
  method: 'GET', // defaults
  url: 'https://.../{user}/{repo}/commits',
  params: {
    user: 'crossjs',
    repo: 'plato'
  },
  query: {
    per_page: 3
  }
  headers: {
    'Accept': 'application/vnd.github.v3+json'
  }
})

use mutate

// asynchronously with promise
request({
  ...,
  mutate (options) {
    return new Promise(function (resolve, reject) {
      // do something,
      // like computing Authorization asynchronously
      resolve(options)
    })
  }
})

// synchronously, new in 0.1.0
request({
  ...,
  mutate (options) {
    // do something,
    // like computing Authorization synchronously
    return options
  }
})

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i plato-request

Weekly Downloads

10

Version

0.1.4

License

MIT

Last publish

Collaborators

  • imliwenfu
  • lmm0591