@shout-sdk/http-request
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@shout-sdk/http-request

shout-http-request is a package to help reduce the amount of boilerplate code when making HTTP requests with fetch.

It contains sensible defaults and handles the conversion of any JavaScript object into a JSON string during POST requests.

Install

npm i @shout-sdk/http-request

Example Usage

// Import the class from the npm package
import { HttpRequest } from '@shout-sdk/http-request';

const getRequest = HttpRequest.get('http://google.com', { 
    'Accept': 'application/json'
});

const postRequest = HttpRequest.post('http://google.com', HttpRequest.DefaultPostHeaders, {
    userId: 1000001,
    email: "email@address.com"
});

// Both methods produce a request ready to pass straight into a fetch call

const getResponse = await fetch(getRequest);

const postResponse = await fetch(postRequest);

/@shout-sdk/http-request/

    Package Sidebar

    Install

    npm i @shout-sdk/http-request

    Weekly Downloads

    0

    Version

    1.0.1

    License

    none

    Unpacked Size

    5.37 kB

    Total Files

    11

    Last publish

    Collaborators

    • daniel-shouts
    • tom-shout
    • karl-shout