A spicy REST client for NodeJS.
npm install chilli-client
npm i chilli-client
`
Usage
$3
`javascript
const chilli = require('chilli-client');
chilli.get('https://google.com')
.then(res => console.log(res));
`
$3
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.
`javascript
chilli.get('https://google.com', {
includeTimings: true
}).then(res => {
console.log(res);
});
`
$3
`javascript
chilli.post('https://google.com', {
name: 'Samantha',
password: 'password',
}, {
includeTimings: true
})
`
$3
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.
`typescript
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
}
``