Skip to content
Raphael Porto edited this page Oct 22, 2017 · 4 revisions

Get started

Translations: Português.

Fitch.js is a lightweight client HTTP that uses Fetch API and runs on Node.js and old browsers (with a polyfill).

Install

You can install Fitch.js using NPM or Yarn:

npm i --save fitch
# or:
# yarn add fitch

Now just import Fitch.js and you are ready to make your first request.

import fitch from 'fitch'
// or:
// const fitch = require('fitch')

const apiUrl = 'https://localhost:8080/'

fitch.get(apiUrl)
  .then(response => console.log(response))

/* Response:
{
  data: { foo: 'bar' },
  status: 200,
  statusText: 'Ok',
  headers: { Content-Type: application/json },
}
*/

Also, you can use cdn:

unpkg

<script src="https://unpkg.com/fitch/dist/index.umd.min.js"></script>

jsDelivr

<script src="https://cdn.jsdelivr.net/g/fitch.js"></script>