@globalfishingwatch/api-client
Advanced tools
Comparing version 0.0.20 to 0.0.21-dataviews8
@@ -111,3 +111,8 @@ "use strict"; | ||
this.token = token; | ||
localStorage.setItem(this.storageKeys.token, token); | ||
if (token) { | ||
localStorage.setItem(this.storageKeys.token, token); | ||
} | ||
else { | ||
localStorage.removeItem(this.storageKeys.token); | ||
} | ||
if (this.debug) { | ||
@@ -122,3 +127,8 @@ console.log('GFWAPI: updated token with', token); | ||
this.refreshToken = refreshToken; | ||
localStorage.setItem(this.storageKeys.refreshToken, refreshToken); | ||
if (refreshToken) { | ||
localStorage.setItem(this.storageKeys.refreshToken, refreshToken); | ||
} | ||
else { | ||
localStorage.removeItem(this.storageKeys.refreshToken); | ||
} | ||
if (this.debug) { | ||
@@ -186,3 +196,6 @@ console.log('GFWAPI: updated refreshToken with', refreshToken); | ||
e_1 = _f.sent(); | ||
throw new Error("Fetch resource not executed as the logged failed with url: " + url); | ||
if (this.debug) { | ||
console.log("Fetch resource executed without login headers in url: " + url); | ||
} | ||
return [3 /*break*/, 4]; | ||
case 4: | ||
@@ -238,2 +251,5 @@ _f.trys.push([4, 6, , 13]); | ||
} | ||
if (e_2 instanceof SyntaxError) { | ||
throw new Error("Error fetching resource: JSON parse failed, try setting fetch options to { json: false } - " + url); | ||
} | ||
throw e_2; | ||
@@ -372,4 +388,4 @@ case 12: return [3 /*break*/, 13]; | ||
case 13: | ||
resolve(null); | ||
return [2 /*return*/, null]; | ||
reject(new Error('No login token provided')); | ||
return [2 /*return*/]; | ||
} | ||
@@ -394,7 +410,11 @@ }); | ||
} | ||
return [4 /*yield*/, fetch(this.baseUrl + "/" + AUTH_PATH + "/logout", { | ||
headers: { | ||
'refresh-token': this.refreshToken, | ||
}, | ||
}).then(processStatus)]; | ||
case 1: | ||
_a.sent(); | ||
this.setToken(''); | ||
this.setRefreshToken(''); | ||
return [4 /*yield*/, this.fetch("/" + AUTH_PATH + "/logout")]; | ||
case 1: | ||
_a.sent(); | ||
if (this.debug) { | ||
@@ -401,0 +421,0 @@ console.log("GFWAPI: Logout invalid session api OK"); |
{ | ||
"name": "@globalfishingwatch/api-client", | ||
"version": "0.0.20", | ||
"version": "0.0.21-dataviews8", | ||
"description": "js library to help with the login/logout and resources fetch of the GFW API", | ||
"keywords": [], | ||
"main": "dist/api-client.umd.js", | ||
"module": "dist/api-client.es5.js", | ||
"typings": "dist/types/api-client.d.ts", | ||
"main": "dist/index.umd.js", | ||
"module": "dist/index.es5.js", | ||
"typings": "dist/types/index.d.ts", | ||
"files": [ | ||
@@ -61,3 +61,4 @@ "dist" | ||
"dependencies": { | ||
"file-saver": "^2.0.2" | ||
"file-saver": "^2.0.2", | ||
"lodash": "^4.17.15" | ||
}, | ||
@@ -72,2 +73,3 @@ "peerDependencies": { | ||
"@types/jest": "^24.0.25", | ||
"@types/lodash": "^4.14.149", | ||
"@types/node": "^13.1.6", | ||
@@ -74,0 +76,0 @@ "@types/react": "^16.9.17", |
@@ -157,6 +157,3 @@ # GFW API CLIENT | ||
```js | ||
const GFWAPI = new GFW_API({ | ||
.... | ||
debug: true | ||
}) | ||
GFWAPI.setConfig({ debug: true }) | ||
``` | ||
@@ -163,0 +160,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
683583
32
7246
4
40
214
13
+ Addedlodash@^4.17.15
+ Addedlodash@4.17.21(transitive)