@bbc/http-transport
Advanced tools
Comparing version
@@ -32,5 +32,5 @@ 'use strict'; | ||
* @example | ||
* const toError = require('http-transport-errors'); | ||
* const toError = require('http-transport-errors'); | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const client = httpTransport.createClient(); | ||
@@ -53,5 +53,5 @@ * client.useGlobal(toError(404)); | ||
* @example | ||
* const toError = require('http-transport-errors'); | ||
* const toError = require('http-transport-errors'); | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* httpTransport.createClient() | ||
@@ -75,3 +75,3 @@ * .use(toError(404)); | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -98,3 +98,3 @@ * .get(url) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -122,3 +122,3 @@ * .post(url, requestBody) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -146,3 +146,3 @@ * .put(url, requestBody) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -169,3 +169,3 @@ * .delete(url) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -192,3 +192,3 @@ * .put(url, requestBody) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -215,6 +215,6 @@ * .head(url) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
* .headers({ | ||
* 'User-Agent' : 'someUserAgent' | ||
* 'User-Agent' : 'someUserAgent' | ||
* }) | ||
@@ -241,6 +241,6 @@ * .asResponse(); | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
* .query({ | ||
* 'perPage' : 1 | ||
* 'perPage' : 1 | ||
* }) | ||
@@ -266,3 +266,3 @@ * .asResponse(); | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -286,3 +286,3 @@ * .timeout(1) | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -298,3 +298,3 @@ * .retry(5) | ||
/** | ||
* Initiates the request, returning the response body, if successful. | ||
* Initiates the request, returning the response body, if successful. | ||
* | ||
@@ -304,6 +304,6 @@ * @method | ||
* @return a Promise. If the Promise fulfils, | ||
* the fulfilment value is the response body, as a string by default. | ||
* the fulfilment value is the response body, as a string by default. | ||
* @example | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -320,3 +320,3 @@ * .asBody() | ||
/** | ||
* Initiates the request, returning a http transport response object, if successful. | ||
* Initiates the request, returning a http transport response object, if successful. | ||
* | ||
@@ -326,6 +326,6 @@ * @method | ||
* @return a Promise. If the Promise fulfils, | ||
* the fulfilment value is response object. | ||
* the fulfilment value is response object. | ||
* @example | ||
* const httpTransport = require('http-transport'); | ||
* | ||
* | ||
* const response = httpTransport.createClient() | ||
@@ -363,3 +363,3 @@ * .asResponse() | ||
function isCriticalError(err) { | ||
if (err && err.statusCode >= 500) { | ||
if (err && (!err.statusCode || err.statusCode >= 500)) { | ||
return true; | ||
@@ -366,0 +366,0 @@ } |
{ | ||
"name": "@bbc/http-transport", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A flexible, modular REST client built for ease-of-use and resilience.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
397706
36.04%81
9.46%8444
63.14%