UNPKG

578 BMarkdownView Raw
1http-call
2=========
3
4[![Greenkeeper badge](https://badges.greenkeeper.io/heroku/http-call.svg)](https://greenkeeper.io/)
5
6Usage
7-----
8
9```js
10const {HTTP} = require('http-call')
11const {body: user} = await HTTP.get('https://api.github.com/users/me')
12// do something with user
13// automatically converts from json
14
15// for typescript specify the type of the body with a generic:
16const {body: user} = await HTTP.get<{id: string, email: string}>('https://api.github.com/users/me')
17
18// set headers
19await HTTP.get('https://api.github.com', {headers: {authorization: 'bearer auth'}})
20```