Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-isomorphic-tools

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-isomorphic-tools - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

170

lib/Fetcher.js

@@ -55,2 +55,3 @@ 'use strict';

case 0:
console.log(baseUrl, url);
headers_data = {};

@@ -60,3 +61,3 @@ body = {};

if (!(method == 'GET' || method == 'DELETE')) {
_context.next = 17;
_context.next = 18;
break;

@@ -69,5 +70,5 @@ }

case 6:
case 7:
if ((_context.t1 = _context.t0()).done) {
_context.next = 15;
_context.next = 16;
break;

@@ -79,3 +80,3 @@ }

if (!params.hasOwnProperty(name)) {
_context.next = 13;
_context.next = 14;
break;

@@ -85,30 +86,30 @@ }

if (params[name]) {
_context.next = 11;
_context.next = 12;
break;
}
return _context.abrupt('continue', 6);
return _context.abrupt('continue', 7);
case 11:
case 12:
query += '' + (i > 0 ? '&' : '?') + name + '=' + params[name];
i++;
case 13:
_context.next = 6;
case 14:
_context.next = 7;
break;
case 15:
case 16:
url += query;
params = undefined;
case 17:
case 18:
_context.t2 = type;
_context.next = _context.t2 === 'form-data' ? 20 : 22;
_context.next = _context.t2 === 'form-data' ? 21 : 23;
break;
case 20:
case 21:
body = params;
return _context.abrupt('break', 24);
return _context.abrupt('break', 25);
case 22:
case 23:
headers_data = {

@@ -120,3 +121,3 @@ 'Accept': 'application/json',

case 24:
case 25:
headers = new Headers(headers_data);

@@ -129,22 +130,22 @@

_context.prev = 26;
_context.next = 29;
_context.prev = 27;
_context.next = 30;
return fetch('' + baseUrl + url, { method: method, headers: headers, body: body, mode: 'cors' });
case 29:
case 30:
data = _context.sent;
if (!(data.status >= 400)) {
_context.next = 81;
_context.next = 82;
break;
}
_context.next = 33;
_context.next = 34;
return data.json();
case 33:
case 34:
error = _context.sent;
if (!(data.status == 401 && (0, _Auth.isAuthenticated)())) {
_context.next = 80;
_context.next = 81;
break;

@@ -156,7 +157,7 @@ }

if (!refreshToken) {
_context.next = 69;
_context.next = 70;
break;
}
_context.next = 39;
_context.next = 40;
return fetch(baseUrl + '/token/refresh', {

@@ -167,8 +168,8 @@ method: 'POST',

case 39:
case 40:
refresh = _context.sent;
_context.next = 42;
_context.next = 43;
return refresh.json();
case 42:
case 43:
response = _context.sent;

@@ -178,3 +179,3 @@ token = response.token, _refreshToken = response.refreshToken;

if (!(refresh.status == 401)) {
_context.next = 58;
_context.next = 59;
break;

@@ -185,3 +186,3 @@ }

headers.delete('Authorization');
_context.next = 49;
_context.next = 50;
return fetch('' + baseUrl + url, {

@@ -194,12 +195,12 @@ method: method,

case 49:
case 50:
_data = _context.sent;
_context.next = 52;
_context.next = 53;
return _data.json();
case 52:
case 53:
_response = _context.sent;
if (!(_data.status == 401)) {
_context.next = 55;
_context.next = 56;
break;

@@ -210,10 +211,10 @@ }

case 55:
case 56:
return _context.abrupt('return', _response);
case 58:
case 59:
(0, _Auth.setToken)(token);
(0, _Auth.setRefreshToken)(_refreshToken);
headers.set('Authorization', 'Bearer ' + (0, _Auth.getToken)());
_context.next = 63;
_context.next = 64;
return fetch('' + baseUrl + url, {

@@ -226,18 +227,18 @@ method: method,

case 63:
case 64:
_data2 = _context.sent;
_context.next = 66;
_context.next = 67;
return _data2.json();
case 66:
case 67:
return _context.abrupt('return', _context.sent);
case 67:
_context.next = 80;
case 68:
_context.next = 81;
break;
case 69:
case 70:
(0, _Auth.logout)();
headers.delete('Authorization');
_context.next = 73;
_context.next = 74;
return fetch('' + baseUrl + url, {

@@ -250,12 +251,12 @@ method: method,

case 73:
case 74:
_data3 = _context.sent;
_context.next = 76;
_context.next = 77;
return _data3.json();
case 76:
case 77:
_response2 = _context.sent;
if (!(_data3.status == 401)) {
_context.next = 79;
_context.next = 80;
break;

@@ -266,18 +267,18 @@ }

case 79:
case 80:
return _context.abrupt('return', _response2);
case 80:
case 81:
throw error;
case 81:
_context.next = 83;
case 82:
_context.next = 84;
return data.json();
case 83:
case 84:
return _context.abrupt('return', _context.sent);
case 86:
_context.prev = 86;
_context.t3 = _context['catch'](26);
case 87:
_context.prev = 87;
_context.t3 = _context['catch'](27);

@@ -287,3 +288,3 @@ console.warn('apiCall [error] - ' + method + ' ' + baseUrl + url + ' -', _context.t3, '- params ' + params);

case 90:
case 91:
case 'end':

@@ -293,3 +294,3 @@ return _context.stop();

}
}, _callee, undefined, [[26, 86]]);
}, _callee, undefined, [[27, 87]]);
}));

@@ -309,2 +310,3 @@

var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(dispatch) {
var response;
return _regenerator2.default.wrap(function _callee2$(_context2) {

@@ -330,31 +332,27 @@ while (1) {

});
_context2.t0 = dispatch;
_context2.t1 = {
key: key
};
_context2.next = 6;
_context2.next = 4;
return fetcher(url, (0, _extends3.default)({}, rest, { params: params }));
case 6:
_context2.t2 = _context2.sent;
_context2.t3 = (0, _extends3.default)({}, rest, {
params: params,
url: url
case 4:
response = _context2.sent;
dispatch({
type: '@FETCH_DATA/SUCCESS',
meta: {
key: key
},
payload: {
response: response,
request: (0, _extends3.default)({}, rest, {
params: params,
url: url
})
}
});
_context2.t4 = {
response: _context2.t2,
request: _context2.t3
};
_context2.t5 = {
type: '@FETCH_DATA/SUCCESS',
meta: _context2.t1,
payload: _context2.t4
};
(0, _context2.t0)(_context2.t5);
_context2.next = 17;
_context2.next = 12;
break;
case 13:
_context2.prev = 13;
_context2.t6 = _context2['catch'](0);
case 8:
_context2.prev = 8;
_context2.t0 = _context2['catch'](0);

@@ -367,8 +365,8 @@ dispatch({

payload: {
error: _context2.t6
error: _context2.t0
}
});
throw _context2.t6;
throw _context2.t0;
case 17:
case 12:
case 'end':

@@ -378,3 +376,3 @@ return _context2.stop();

}
}, _callee2, undefined, [[0, 13]]);
}, _callee2, undefined, [[0, 8]]);
}));

@@ -381,0 +379,0 @@

{
"name": "react-isomorphic-tools",
"version": "1.1.4",
"version": "1.1.5",
"description": "Authorization, Fetcher, Preload. Tools for ServerSide rendering",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -8,2 +8,3 @@ import {getTokenPrefix, isAuthenticated, getToken, getRefreshToken, logout, setToken, setRefreshToken} from './Auth'

const fetcher = async(url, {params, type = null, baseUrl = BaseUrl, method = 'GET'} = {}) => {
console.log(baseUrl, url)
let headers_data = {}

@@ -129,2 +130,3 @@ let body = {}

})
const response = await fetcher(url, {...rest, params})
dispatch({

@@ -136,3 +138,3 @@ type: '@FETCH_DATA/SUCCESS',

payload: {
response: await fetcher(url, {...rest, params}),
response: response,
request: {

@@ -139,0 +141,0 @@ ...rest,

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