Socket
Socket
Sign inDemoInstall

mappersmith

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mappersmith - npm Package Compare versions

Comparing version 2.21.0 to 2.22.0

6

gateway.js

@@ -56,3 +56,3 @@ 'use strict';

} catch (e) {
_this.dispatchClientError(e.message);
_this.dispatchClientError(e.message, e);
}

@@ -64,4 +64,4 @@ });

},
dispatchClientError: function dispatchClientError(message) {
this.failCallback(new _response2.default(this.request, 400, message));
dispatchClientError: function dispatchClientError(message, error) {
this.failCallback(new _response2.default(this.request, 400, message, {}, [error]));
},

@@ -68,0 +68,0 @@ prepareBody: function prepareBody(method, headers) {

@@ -82,3 +82,4 @@ 'use strict';

canceled = true;
_this.dispatchClientError('Timeout (' + timeout + 'ms)');
var error = new Error('Timeout (' + timeout + 'ms)');
_this.dispatchClientError(error.message, error);
}, timeout);

@@ -114,3 +115,3 @@ }

clearTimeout(timer);
_this.dispatchClientError(error.message);
_this.dispatchClientError(error.message, error);
});

@@ -117,0 +118,0 @@ },

@@ -101,3 +101,4 @@ 'use strict';

_this.canceled = true;
_this.dispatchClientError('Timeout (' + timeout + 'ms)');
var error = new Error('Timeout (' + timeout + 'ms)');
_this.dispatchClientError(error.message, error);
});

@@ -132,3 +133,3 @@ }

this.dispatchClientError(e.message);
this.dispatchClientError(e.message, e);
},

@@ -135,0 +136,0 @@ createResponse: function createResponse(httpResponse, rawData) {

@@ -94,3 +94,3 @@ 'use strict';

xmlHttpRequest.addEventListener('error', function () {
xmlHttpRequest.addEventListener('error', function (e) {
if (_this2.canceled) {

@@ -101,3 +101,8 @@ return;

clearTimeout(_this2.timer);
_this2.dispatchClientError('Network error');
var guessedErrorCause = e ? e.message || e.name : xmlHttpRequest.responseText;
var errorMessage = 'Network error';
var enhancedMessage = guessedErrorCause ? ': ' + guessedErrorCause : '';
var error = new Error('' + errorMessage + enhancedMessage);
_this2.dispatchClientError(errorMessage, error);
});

@@ -104,0 +109,0 @@

@@ -18,3 +18,3 @@ 'use strict';

/* global VERSION */
var version = exports.version = '2.21.0';
var version = exports.version = '2.22.0';

@@ -21,0 +21,0 @@ var configs = exports.configs = {

{
"name": "mappersmith",
"version": "2.21.0",
"version": "2.22.0",
"description": "It is a lightweight rest client for node.js and the browser",

@@ -5,0 +5,0 @@ "author": "Tulio Ornelas <ornelas.tulio@gmail.com>",

@@ -323,2 +323,3 @@ [![npm version](https://badge.fury.io/js/mappersmith.svg)](http://badge.fury.io/js/mappersmith)

* `data()` - Returns the response data, if `Content-Type` is `application/json` it parses the response and returns an object
* `error()` - Returns the last error instance that caused the request to fail or `null`

@@ -325,0 +326,0 @@ ## <a name="middleware"></a> Middleware

@@ -9,2 +9,4 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/**

@@ -16,4 +18,5 @@ * @typedef Response

* @param {Object} responseHeaders, defaults to an empty object ({})
* @param {Array<Error>} errors, defaults to an empty array ([])
*/
function Response(originalRequest, responseStatus, responseData, responseHeaders) {
function Response(originalRequest, responseStatus, responseData, responseHeaders, errors) {
if (originalRequest.requestParams && originalRequest.requestParams.auth) {

@@ -29,2 +32,3 @@ var maskedAuth = (0, _utils.assign)({}, originalRequest.requestParams.auth, { password: '***' });

this.responseHeaders = responseHeaders || {};
this.errors = errors || [];
this.timeElapsed = null;

@@ -121,2 +125,17 @@ }

/**
* Returns the last error instance that caused the request to fail
*
* @return {Error|null}
*/
error: function error() {
var lastError = this.errors[this.errors.length - 1] || null;
if (typeof lastError === 'string') {
return new Error(lastError);
}
return lastError;
},
/**
* Enhances current Response returning a new Response

@@ -128,2 +147,3 @@ *

* @param {Object} extras.headers - it will be merged with current headers
* @param {Error} extras.error - it will be added to the list of errors
*

@@ -133,3 +153,3 @@ * @return {Response}

enhance: function enhance(extras) {
return new Response(this.request(), extras.status || this.status(), extras.rawData || this.rawData(), (0, _utils.assign)({}, this.headers(), extras.headers));
return new Response(this.request(), extras.status || this.status(), extras.rawData || this.rawData(), (0, _utils.assign)({}, this.headers(), extras.headers), [].concat(_toConsumableArray(this.errors), [extras.error]));
}

@@ -136,0 +156,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc