-
Notifications
You must be signed in to change notification settings - Fork 5
Home
Raphael Porto edited this page Oct 22, 2017
·
4 revisions
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).
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>