Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kahwee/fetch-json

Wrapper around fetch API specific for JSON
https://github.com/kahwee/fetch-json

Last synced: about 2 months ago
JSON representation

Wrapper around fetch API specific for JSON

Awesome Lists containing this project

README

        

## fetch-json

Wrapper around fetch specific for JSON.

## `fetch-json/post`

This function use Fetch API and adds in the relevant JSON headers for you:

```
method: 'post',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
```

## Example usage

```js
var postJSON = require('fetch-json/post');
postJSON('/api/login', {
body: {
username: 'kahwee',
password: '!password1'
}
}).then(function(data) {
console.log(data, 'done');
});
```