1.0.3 • Published 7 years ago
simple-json-api-wrapper v1.0.3
Description
This is just a simple package that wraps the fetch API, and returns JSON.
Usage
There are three methods (get, post, put), wich all return a promise. Arguments:
url: A string to the url or endpoint you want to call. body: A object containing the info you would like to POST or PUT.
Example
import Api from "simple-json-api-wrapper";
// All methods return a promise.
const promise = Api.get(url);
promise.then((json) => {
// Do something with JSON.
console.log(json);
});
/*
* @param url {String} The url you are trying to call.
* @param body {Object} A object of the data you would like to POST or PUT.
*/
Api.post(url, body);
Api.put(url, body);