Fitch.js
A lightweight Promise based HTTP client, using Fetch API.
Get started
Install
npm i --save fitch
Use
** With ES2015 or TypeScript:**
import fitch from 'fitch'
CommonJS:
const fitch = require('fitch')
UMD:
<script src="node_modules/fitch/src/index.js"></script>
Make your first request:
fitch.get(apiUrl)
.then(data => console.log(data))
Methods available:
get
fitch.get(apiUrl)
.then(data => console.log(data))
post
const req = {body: {name: 'Happy cat'}}
fitch.get(apiUrl, req)
.then(data => console.log(data))
put
const req = {body: {name: 'Happy cat'}}
fitch.get(apiUrl, req)
.then(data => console.log(data))
patch
const req = {body: {name: 'Happy cat'}}
fitch.get(apiUrl, req)
.then(data => console.log(data))
delete
fitch.get(apiUrl)
.then(data => console.log(data))
Use with custom configuration
fitch.get(apiUrl, config)
.then(data => console.log(data))
Contributig
First yout need to fork this repository. Then:
npm i
npm start
npm run watch:test
npm run examples
It is important that the code can be tested and pass in linter check.
You can verify your code with ESLint, using npm run lint
.