2.0.11 • Published 3 years ago

encharge-request v2.0.11

Weekly downloads
6
License
BSD-3-Clause
Repository
github
Last release
3 years ago

This module implements a Zapier-inspired node-fetch modification.

Usage:

const { request } = require("request");
// Note: Only the URL is required.
request("https://example.com", {
  method: "POST",
  // Set headers
  headers: {
    "X-Header": "Heads up"
  },
  // You can add query parameters:
  params: {
    key: "will be added as a query parameter"
  },
  // Send the body as string
  body: "Can be a string",
  // Or as JSON (sets the Content-Type header to application/json)
  json: {
    Winter: "Fell"
  },
  // Or Form encoded (sets the Content-Type header to www-x-form-urlencoded)
  form: {
    John: "Snow"
  },
  // And other options:
  follow, // max redirect count, 0 for no limit.
  compress, // set to false to disable gzip content encoding.
  timeout, // Request timeout. Set to 0 to disable. Default 0.
  size // Request size limit. Set to 0 to disable. Default 0.
});

Then response is a promise with the following structure:

{
  status, // HTTP status code
    headers, // Response headers as a dict
    content, // Response as text
    json, // Response parsed as JSON, if possible.
    request, // Options object (see above that fired the request).
    getHeader, // Helper function to get header by name.
    throwForStatus; // Helper function that throws if the status > 300.
}
2.0.11

3 years ago

2.0.10

5 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago