@evokegroup/webrequest
TypeScript icon, indicating that this package has built-in type declarations

2.0.5 • Public • Published

@evokegroup/webrequest

Utility for making HTTP/HTTPS calls.

CommonJS

const { webRequest } = require('@evokgroup/webrequest');

ES Modules

import { webRequest } from '@evokegroup/webrequest';

Usage

webRequest({
  url: 'https://some.url.com',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: { send: 'this' },
  parseResponse: true // Pase true to parse the body as JSON data or return a string. Otherwise the response body will be a Buffer
})
  .then((webResponse) => {
    if (webResponse.statusCode === 200) {
      const data = webResponse.body; // parseResponse=true parsed the body and JSON data
      const name = data.name;
    } else {
      // do something
    }
  })
  .catch(reject);

Readme

Keywords

none

Package Sidebar

Install

npm i @evokegroup/webrequest

Weekly Downloads

2

Version

2.0.5

License

ISC

Unpacked Size

14.6 kB

Total Files

14

Last publish

Collaborators

  • ybevoke
  • jtsuyuki
  • evokejames
  • evoke-cjamodeo