Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/fettuccine-class
A class to create a new fettuccine wrapper that defaults to the given options
https://github.com/shinnn/fettuccine-class
class fetch http https javascript nodejs promise request
Last synced: 27 days ago
JSON representation
A class to create a new fettuccine wrapper that defaults to the given options
- Host: GitHub
- URL: https://github.com/shinnn/fettuccine-class
- Owner: shinnn
- License: isc
- Created: 2015-12-22T11:11:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-13T05:28:14.000Z (about 6 years ago)
- Last Synced: 2024-04-14T08:42:45.301Z (7 months ago)
- Topics: class, fetch, http, https, javascript, nodejs, promise, request
- Language: JavaScript
- Homepage: https://github.com/shinnn/fettuccine
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fettuccine-class
[![npm version](https://img.shields.io/npm/v/fettuccine-class.svg)](https://www.npmjs.com/package/fettuccine-class)
[![Build Status](https://travis-ci.org/shinnn/fettuccine-class.svg?branch=master)](https://travis-ci.org/shinnn/fettuccine-class)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/fettuccine-class.svg)](https://coveralls.io/github/shinnn/fettuccine-class)A [class](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Classes) to create a new [`fettuccine`](https://github.com/shinnn/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](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install fettuccine-class
```## API
```javascript
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()`](https://github.com/shinnn/fettuccine#fettuccineurl--options), but uses options passed to the constructor by default.
```javascript
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](./LICENSE) © 2018 Shinnosuke Watanabe