plato-request
v0.1.4
Published
:vertical_traffic_light: A Request Library based on the Fetch API
Downloads
240
Readme
PLATO-REQUEST
:vertical_traffic_light: A Request Library based on the Fetch API
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
}
})