Package Exports
- file-or-stdout
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (file-or-stdout) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
fettuccine
A simplified HTTP(S) client for Node
- with the Promise API
- and every imaginable option thanks to Request,
- nevertheless, keeping small package size by economical module loading
const fettuccine = require('fettuccine');
fettuccine('https://api.github.com/users/isaacs/repos', {
qs: {sort: 'created'},
json: true
}).then(response => {
response.body[0]; //=> {id: 46883374, name: 'pseudomap', ...}
});
Installation
npm install fettuccine
API
const fettuccine = require('fettuccine');
fettuccine(url [, options])
url: String
(URL to send a request)
options: Object
(used as Request
options with gzip
defaulting to true
)
Return: Object
(Promise
instance)
It makes an HTTP or HTTPS request to the given URL.
When the request finishes, it will be fulfilled with the http.IncomingMessage
object with the additional body
property:
response
body (String
orBuffer
, or JSON object if thejson
option is supplied)
When the request fails, it will be rejected with an error object (usually from http.ClientRequest
object).
fettuccine.get()
Alias of fettuccine()
.
fettuccine.post(), fettuccine.put(), fettuccine.patch(), fettuccine.head(), fettuccine.delete()
Set options.method
to the method name and call fettuccine()
.
const fettuccine = require('fettuccine');
// With `fettuccine()`
fettuccine('https://awesome-webservice.com/api', {
method: 'POST',
body: new Buffer(/* image buffer */)
}).then(() => console.log('Uploaded an image.'));
// With `fettuccine.post()`
fettuccine.post('https://awesome-webservice.com/api', {
body: new Buffer(/* image buffer */)
}).then(() => console.log('Uploaded an image.'));
fettuccine.Fettuccine([options])
The Fettuccine
class.
License
Copyright (c) 2015 - 2016 Shinnosuke Watanabe
Licensed under the MIT License.