twopi-network-utils

A set of network utilities to improve code reusability across javascript projects.

Usage no npm install needed!

<script type="module">
  import twopiNetworkUtils from 'https://cdn.skypack.dev/twopi-network-utils';
</script>

README

twopicode-network-utils


Instructions

import { requestFactory, GET, POST, POST_FILE, PUT, DELETE, PATCH } from 'twopicode-network-utils'

const get = requestFactory(GET)
const post = requestFactory(POST)
const post_file = requestFactory(POST_FILE)
const put = requestFactory(PUT)
const delete = requestFactory(DELETE)
const patch = requestFactory(PATCH)


get('http://example.com/api').then(resp => {
    console.log(resp)
})

You can optionally pass a function to the factory that triggers a notification. The function takes a single string - the message to be printed.

For any more information you'll have to read the source, sorry!