Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kahwee/fetch-json
- Owner: kahwee
- Created: 2015-04-19T15:18:20.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-29T13:02:20.000Z (over 7 years ago)
- Last Synced: 2024-04-12T16:21:32.638Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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');
});
```