1. http-response-object
A simple object to represent an http response
http-response-object
Package: http-response-object
Created by: ForbesLindesay
Last modified: Sat, 18 Jun 2022 22:15:22 GMT
Version: 3.0.2
License: MIT
Downloads: 4,029,917
Repository: https://github.com/ForbesLindesay/http-response-object

Install

npm install http-response-object
yarn add http-response-object

http-response-object

A simple object to represent an http response (with flow and typescript types)

Build Status
Dependency Status
NPM version

Installation

npm install http-response-object

Usage

 var Response = require('http-response-object');
var res = new Response(200, {}, new Buffer('A ok'), 'http://example.com');
//res.statusCode === 200
//res.headers === {}
//res.body === new Buffer('A ok')
//res.url === 'http://example.com'
res.getBody();
// => new Buffer('A ok')

var res = new Response(404, {'Header': 'value'}, new Buffer('Wheres this page'), 'http://example.com');
//res.statusCode === 404
//res.headers === {header: 'value'}
//res.body === new Buffer('Wheres this page')
//res.url === 'http://example.com'
res.getBody();
// => throws error with `statusCode`, `headers`, `body` and `url` properties copied from the response

Properties

  • statusCode: Number - the status code of the response
  • headers: Object - the headers of the response. The keys are automatically made lower case.
  • body: Buffer | String - the body of the response. Should be a buffer on the server side, but may be a simple string for lighter weight clients.
  • url: String - the url that was requested. If there were redirects, this should be the last url to get requested.

License

MIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin