Send HTTP request and get response.
- Send HTTP request and get response
- Send multiple requests sequentially in the same file (separated by
###delimiter) - Comments support (line starts with
#)
npm install @codeit-com/raw-httpFollow the standard RFC2616 that including request method, uri, headers, and body.
const{ RawHttpClient }=require("@codeit-com/raw-http")consthttpRequest=`POST https://jsonplaceholder.typicode.com/posts HTTP/1.1Content-type: application/json; charset=UTF-8{ title: 'foo', body: 'bar', userId: 1,}`constclient=newRawHttpClient({beautify: true})client.requestAll(httpRequest).then(responses=>{console.log(responses[0])})// HTTP/1.1 201 Created// Date: Wed, 09 Jun 2021 01:22:56 GMT// ...// // {// id: 101,// title: 'foo',// body: 'bar',// userId: 1// }Create a RawHttpClient instance.
{beautify: boolean// Beautify response body if it's JSON. Default is false.}Execute all requests in rawRequestsText and return raw responses.