simple-json-api-wrapper

Simple fetch wrapper

Usage no npm install needed!

<script type="module">
  import simpleJsonApiWrapper from 'https://cdn.skypack.dev/simple-json-api-wrapper';
</script>

README

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);