fettuccine

1.0.4 • Public • Published

fettuccine

npm version Build Status Coverage Status Dependency Status devDependency Status

A simplified HTTP client for Node

const fettuccine = require('fettuccine');
 
(async () => {
  const response = await fettuccine('https://api.github.com/users/isaacs/repos', {
    qs: {sort: 'created'},
    json: true
  });
 
  response.body[0]; //=> {id: 46883374, name: 'pseudomap', ...}
})();

Installation

Use npm.

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: Promise<Object>

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 or Buffer, or JSON object if the json 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()`
(async () => {
  await fettuccine('https://awesome-webservice.com/api', {
    method: 'POST',
    body: imageBuffer
  });
 
  console.log('Uploaded an image.')
})();
 
// With `fettuccine.post()`
(async () => {
  await fettuccine.post('https://awesome-webservice.com/api', {
    body: imageBuffer
  });
 
  console.log('Uploaded an image.')
})();

fettuccine.Fettuccine([options])

The Fettuccine class.

License

ISC License © 2018 Shinnosuke Watanabe

Package Sidebar

Install

npm i fettuccine

Weekly Downloads

22

Version

1.0.4

License

ISC

Unpacked Size

5.63 kB

Total Files

4

Last publish

Collaborators

  • shinnn