A very small wrapper around the base node https client that allows you to make requests using Promises and a familiar API.
npm i chilli-client
const chilli = require('chilli-client');
chilli.get('https://google.com')
.then(res => console.log(res));
chilli-client accepts the standard https.request options object outlined here. Additionally, you can add the
includeTimings
and includeRawResponse
properties to the options object to include an object that contains the time it took various parts of the request to run and the raw
http.IncomingMessage
contents.
chilli.get('https://google.com', {
includeTimings: true
}).then(res => {
console.log(res);
});
chilli.post('https://google.com', {
name: 'Samantha',
password: 'password',
}, {
includeTimings: true
})
chilli-client returns a developer-friendly response object. It does not make any assumptions about the response, and, unlike similar http clients, will not automatically throw an error when the status code is outside of the 200 range.
interface ChilliResponse {
body: string | Object, // will decode response body to JavaScript object if Content-Type header is application/json
statusCode: number,
statusMessage: string,
raw: http.IncomingMessage,
timings: Timings
}
interface Timings {
total: number,
dnsLookup: number,
tcpConnection: number,
tlsHandshake: number,
firstByte: number,
streamRes: number
}