fettuccine-class

2.0.0 • Public • Published

fettuccine-class

npm version Build Status Coverage Status

A class to create a new fettuccine wrapper that defaults to given options.

Basically end users would rather use fettuccine directly, which covers most use cases. fettucine-class is designed for library authors to create an HTTP client interacting with a specific web service or API.

Installation

Use npm.

npm install fettuccine-class

API

const Fettuccine = require('fettuccine-class');

instance = new Fettuccine([options])

options: Object (used as default options of instance methods)
Return: Object

instance.fetch(url [, options])

Same as fettuccine(), but uses options passed to the constructor by default.

const packageInfo = new Fettuccine({
  baseUrl: 'https://registry.npmjs.org/'
});
 
(async () => {
  const {description} = await (await packageInfo.fetch('npm')).json();
  //=> 'a package manager for JavaScript'
})();

instance.delete(url [, options]), instance.get(url [, options]),, instance.head(url [, options]), instance.patch(url [, options]), instance.post(url [, options]), instance.put(url [, options])

Set options.method to the corresponding method name and call instance.fetch(). In those function options.method is not configurable.

instance.option

Default options used by instance.fetch().

License

ISC License © 2018 Shinnosuke Watanabe

Package Sidebar

Install

npm i fettuccine-class

Weekly Downloads

264

Version

2.0.0

License

ISC

Unpacked Size

5 kB

Total Files

4

Last publish

Collaborators

  • shinnn