nordnet-next-api
Advanced tools
Comparing version 3.3.0 to 4.0.0
@@ -29,3 +29,2 @@ 'use strict'; | ||
var HTTP_BAD_REQUEST = 400; | ||
var HTTP_FORBIDDEN = 403; | ||
var regUrlParam = /{([\s\S]+?)}/g; | ||
@@ -176,23 +175,3 @@ | ||
var request = function request() { | ||
return fetch(fetchUrl, fetchParams).then(validateStatus).then(saveNTag).then(processResponse); | ||
}; | ||
var getNTag = function getNTag() { | ||
return fetch('/api/2/login').then(validateStatus).then(saveNTag); | ||
}; | ||
/** | ||
* If the response status code is 403, the reason may be | ||
* an invalid ntag. Try to get a valid one, and retry the | ||
* request. | ||
*/ | ||
return request().catch(function (response) { | ||
if (response.status === HTTP_FORBIDDEN) { | ||
return getNTag().then(request).catch(function () { | ||
return validateStatus(response); | ||
}); | ||
} | ||
return validateStatus(response); | ||
}); | ||
return fetch(fetchUrl, fetchParams).then(validateStatus).then(saveNTag).then(processResponse); | ||
} | ||
@@ -199,0 +178,0 @@ |
{ | ||
"name": "nordnet-next-api", | ||
"version": "3.3.0", | ||
"version": "4.0.0", | ||
"description": "Nordnet nExt API Javascript client", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -9,3 +9,2 @@ import es6Promise from 'es6-promise'; | ||
const HTTP_BAD_REQUEST = 400; | ||
const HTTP_FORBIDDEN = 403; | ||
const regUrlParam = /{([\s\S]+?)}/g; | ||
@@ -128,24 +127,6 @@ | ||
const request = () => fetch(fetchUrl, fetchParams) | ||
return fetch(fetchUrl, fetchParams) | ||
.then(validateStatus) | ||
.then(saveNTag) | ||
.then(processResponse); | ||
const getNTag = () => fetch('/api/2/login') | ||
.then(validateStatus) | ||
.then(saveNTag); | ||
/** | ||
* If the response status code is 403, the reason may be | ||
* an invalid ntag. Try to get a valid one, and retry the | ||
* request. | ||
*/ | ||
return request().catch((response) => { | ||
if (response.status === HTTP_FORBIDDEN) { | ||
return getNTag() | ||
.then(request) | ||
.catch(() => validateStatus(response)); | ||
} | ||
return validateStatus(response); | ||
}); | ||
} | ||
@@ -152,0 +133,0 @@ |
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
3
53736
1369