h2io-fetch

0.0.2 • Public • Published

H2io - Fetch

Installation

npm install h2io-fetch

Usage

GET

import { jsonFetch } from 'h2io-fetch';

jsonFetch('//example.com')
  .then((obj) => console.log('response obj', obj))
  .catch((e) => throw new Error(e));

POST

If we pass body fetch method will be post

import { jsonFetch } from 'h2io-fetch';

const body = {
  firstName: 'John',
  lastName: 'Doe',
};

jsonFetch('//example.com', { body })
  .then((obj) => console.log('response obj', obj))
  .catch((e) => console.error(e));

Options (default)

const opts = {
  method: 'get',
  mode: 'cors',
  credentials: 'include',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
}

Readme

Keywords

none

Package Sidebar

Install

npm i h2io-fetch

Weekly Downloads

0

Version

0.0.2

License

ISC

Last publish

Collaborators

  • h2io