Skip to content
HTTP client with every imaginable option and small file size
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
index.js
package-lock.json
package.json
test.js

README.md

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

You can’t perform that action at this time.