@evokegroup/webrequest
v2.0.5
Published
Utility for making HTTP/HTTPS calls
Downloads
17
Keywords
Readme
@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);