fetch-get-param

1.2.6 • Public • Published

Fetch-Get-Params

a fetch get request that accepts params as an objects and sends request in the URL approprietly , since that is not supported in fetch.

usage

example 1

import { Get} from 'fetch-get-param';

Get(url , {key:value, key2:value2})
  .then(res=>res.json())
   .then(response => console.log('response'))
   .catch(err => console.log('err', err));

Fetch get param uses fetch Behind the scene , so make sure your setup allows that

example 2

import { Get} from 'fetch-get-param';

// if you are using node js
//cons fetchGet = require('fetch-get-param');
// const {Get} = fetchGet;

  Get(url , options , headers)
  .then(function (response) { if(!response.ok) { throw new Error('Error on Network); return response.json() })
  .then(res => console.log('response is ', Json.parse(res))
  .catch(err => console.err('we have an err', err))

you can use the Post , Put the same way

Readme

Keywords

Package Sidebar

Install

npm i fetch-get-param

Weekly Downloads

0

Version

1.2.6

License

ISC

Unpacked Size

4.02 kB

Total Files

4

Last publish

Collaborators

  • henoktsegaye