react-isomorphic-tools
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -32,10 +32,4 @@ 'use strict'; | ||
dispatch = _ref2$store.dispatch, | ||
_ref2$renderProps = _ref2.renderProps, | ||
components = _ref2$renderProps.components, | ||
routes = _ref2$renderProps.routes, | ||
params = _ref2$renderProps.params, | ||
location = _ref2$renderProps.location, | ||
router = _ref2$renderProps.router, | ||
props = (0, _objectWithoutProperties3.default)(_ref2$renderProps, ['components', 'routes', 'params', 'location', 'router']); | ||
var i; | ||
renderProps = _ref2.renderProps; | ||
var components, routes, params, location, router, props, i; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
@@ -45,10 +39,20 @@ while (1) { | ||
case 0: | ||
if (renderProps) { | ||
_context.next = 2; | ||
break; | ||
} | ||
return _context.abrupt('return'); | ||
case 2: | ||
components = renderProps.components, routes = renderProps.routes, params = renderProps.params, location = renderProps.location, router = renderProps.router, props = (0, _objectWithoutProperties3.default)(renderProps, ['components', 'routes', 'params', 'location', 'router']); | ||
components = (0, _preload2.getComponents)(components); | ||
if (!components.length) { | ||
_context.next = 19; | ||
_context.next = 22; | ||
break; | ||
} | ||
_context.prev = 2; | ||
_context.prev = 5; | ||
@@ -58,5 +62,5 @@ dispatch((0, _preload.start)()); | ||
case 5: | ||
case 8: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 13; | ||
_context.next = 16; | ||
break; | ||
@@ -68,7 +72,7 @@ } | ||
if (!components.hasOwnProperty(i)) { | ||
_context.next = 11; | ||
_context.next = 14; | ||
break; | ||
} | ||
_context.next = 10; | ||
_context.next = 13; | ||
return components[i].preload({ | ||
@@ -87,3 +91,3 @@ getState: getState, | ||
case 10: | ||
case 13: | ||
dispatch((0, _preload.push)({ | ||
@@ -95,18 +99,18 @@ displayName: components[i].displayName, | ||
case 11: | ||
_context.next = 5; | ||
case 14: | ||
_context.next = 8; | ||
break; | ||
case 13: | ||
case 16: | ||
dispatch((0, _preload.finish)()); | ||
_context.next = 19; | ||
_context.next = 22; | ||
break; | ||
case 16: | ||
_context.prev = 16; | ||
_context.t2 = _context['catch'](2); | ||
case 19: | ||
_context.prev = 19; | ||
_context.t2 = _context['catch'](5); | ||
dispatch((0, _preload.error)(_context.t2)); | ||
case 19: | ||
case 22: | ||
case 'end': | ||
@@ -116,3 +120,3 @@ return _context.stop(); | ||
} | ||
}, _callee, undefined, [[2, 16]]); | ||
}, _callee, undefined, [[5, 19]]); | ||
})); | ||
@@ -119,0 +123,0 @@ |
@@ -32,3 +32,3 @@ 'use strict'; | ||
var BASE_URL = void 0; | ||
var BaseUrl = void 0; | ||
@@ -41,4 +41,4 @@ var fetcher = function () { | ||
type = _ref2$type === undefined ? null : _ref2$type, | ||
_ref2$base_url = _ref2.base_url, | ||
base_url = _ref2$base_url === undefined ? BASE_URL : _ref2$base_url, | ||
_ref2$baseUrl = _ref2.baseUrl, | ||
baseUrl = _ref2$baseUrl === undefined ? BaseUrl : _ref2$baseUrl, | ||
_ref2$method = _ref2.method, | ||
@@ -123,3 +123,3 @@ method = _ref2$method === undefined ? 'GET' : _ref2$method; | ||
_context.next = 29; | ||
return fetch('' + base_url + url, { method: method, headers: headers, body: body, mode: 'cors' }); | ||
return fetch('' + baseUrl + url, { method: method, headers: headers, body: body, mode: 'cors' }); | ||
@@ -153,3 +153,3 @@ case 29: | ||
_context.next = 39; | ||
return fetch(base_url + '/token/refresh', { | ||
return fetch(baseUrl + '/token/refresh', { | ||
method: 'POST', | ||
@@ -176,3 +176,3 @@ body: (0, _stringify2.default)({ refreshToken: _refreshToken }) | ||
_context.next = 49; | ||
return fetch('' + base_url + url, { | ||
return fetch('' + baseUrl + url, { | ||
method: method, | ||
@@ -207,3 +207,3 @@ headers: headers, | ||
_context.next = 63; | ||
return fetch('' + base_url + url, { | ||
return fetch('' + baseUrl + url, { | ||
method: method, | ||
@@ -231,3 +231,3 @@ headers: headers, | ||
_context.next = 73; | ||
return fetch('' + base_url + url, { | ||
return fetch('' + baseUrl + url, { | ||
method: method, | ||
@@ -271,3 +271,3 @@ headers: headers, | ||
console.warn('apiCall [error] - ' + method + ' ' + base_url + url + ' -', _context.t3, '- params ' + params); | ||
console.warn('apiCall [error] - ' + method + ' ' + baseUrl + url + ' -', _context.t3, '- params ' + params); | ||
throw _context.t3; | ||
@@ -369,3 +369,3 @@ | ||
var setBaseUrl = function setBaseUrl(url) { | ||
BASE_URL = url; | ||
BaseUrl = url; | ||
}; | ||
@@ -372,0 +372,0 @@ |
{ | ||
"name": "react-isomorphic-tools", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Authorization, Fetcher, Preload. Tools for ServerSide rendering", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -6,3 +6,5 @@ import {push, start, finish, error} from '../actions/preload' | ||
export default async({store:{getState, dispatch}, renderProps:{components, routes, params, location, router, ...props}})=> { | ||
export default async({store:{getState, dispatch}, renderProps})=> { | ||
if(!renderProps) return; | ||
let {components, routes, params, location, router, ...props} = renderProps | ||
components = getComponents(components) | ||
@@ -9,0 +11,0 @@ if (components.length) { |
@@ -5,5 +5,5 @@ import {getTokenPrefix, isAuthenticated, getToken, getRefreshToken, logout, setToken, setRefreshToken} from './Auth' | ||
let BASE_URL | ||
let BaseUrl | ||
const fetcher = async(url, {params, type = null, base_url = BASE_URL, method = 'GET'} = {}) => { | ||
const fetcher = async(url, {params, type = null, baseUrl = BaseUrl, method = 'GET'} = {}) => { | ||
let headers_data = {} | ||
@@ -47,3 +47,3 @@ let body = {} | ||
try { | ||
const data = await fetch(`${base_url}${url}`, {method: method, headers: headers, body: body, mode: 'cors'}) | ||
const data = await fetch(`${baseUrl}${url}`, {method: method, headers: headers, body: body, mode: 'cors'}) | ||
if (data.status >= 400) { | ||
@@ -54,3 +54,3 @@ const error = await data.json() | ||
if (refreshToken) { | ||
const refresh = await fetch(`${base_url}/token/refresh`, { | ||
const refresh = await fetch(`${baseUrl}/token/refresh`, { | ||
method: 'POST', | ||
@@ -64,3 +64,3 @@ body: JSON.stringify({refreshToken: refreshToken}) | ||
headers.delete('Authorization') | ||
const data = await fetch(`${base_url}${url}`, { | ||
const data = await fetch(`${baseUrl}${url}`, { | ||
method: method, | ||
@@ -80,3 +80,3 @@ headers: headers, | ||
headers.set('Authorization', `Bearer ${getToken()}`) | ||
const data = await fetch(`${base_url}${url}`, { | ||
const data = await fetch(`${baseUrl}${url}`, { | ||
method: method, | ||
@@ -93,3 +93,3 @@ headers: headers, | ||
headers.delete('Authorization') | ||
const data = await fetch(`${base_url}${url}`, { | ||
const data = await fetch(`${baseUrl}${url}`, { | ||
method: method, | ||
@@ -112,3 +112,3 @@ headers: headers, | ||
catch (e) { | ||
console.warn(`apiCall [error] - ${method} ${base_url}${url} -`, e, `- params ${params}`) | ||
console.warn(`apiCall [error] - ${method} ${baseUrl}${url} -`, e, `- params ${params}`) | ||
throw e | ||
@@ -162,5 +162,5 @@ } | ||
const setBaseUrl = (url) => { | ||
BASE_URL = url | ||
BaseUrl = url | ||
} | ||
export {fetcher, setBaseUrl, fetchToState} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61311
1435