akio-browser
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -183,4 +183,3 @@ "use strict"; | ||
this.logger.verbose("'init' with token: ".concat(token, ".")); | ||
_context2.prev = 4; | ||
_context2.next = 7; | ||
_context2.next = 6; | ||
return this.post({ | ||
@@ -194,9 +193,18 @@ path: '/init', | ||
case 7: | ||
case 6: | ||
response = _context2.sent; | ||
_context2.next = 10; | ||
_context2.next = 9; | ||
return response.json(); | ||
case 10: | ||
case 9: | ||
json = _context2.sent; | ||
if (!(response.status !== 200)) { | ||
_context2.next = 12; | ||
break; | ||
} | ||
return _context2.abrupt("return", this.logger.error("Failed to init: ".concat(json.error))); | ||
case 12: | ||
// If we get a valid response, save the session_id. | ||
@@ -208,11 +216,4 @@ this.sessionId = json.session_id; | ||
}); | ||
_context2.next = 18; | ||
break; | ||
case 15: | ||
_context2.prev = 15; | ||
_context2.t0 = _context2["catch"](4); | ||
this.logger.error("Failed to init: ".concat(_context2.t0.message)); | ||
case 18: | ||
case 14: | ||
case "end": | ||
@@ -222,3 +223,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, this, [[4, 15]]); | ||
}, _callee2, this); | ||
})); | ||
@@ -225,0 +226,0 @@ |
{ | ||
"name": "akio-browser", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "build/akio.js", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -82,20 +82,20 @@ // Libraries | ||
this.logger.verbose(`'init' with token: ${token}.`); | ||
try { | ||
const response = await this.post({ | ||
path: '/init', | ||
params: { | ||
token, | ||
sessionId, | ||
}, | ||
}); | ||
const response = await this.post({ | ||
path: '/init', | ||
params: { | ||
token, | ||
sessionId, | ||
}, | ||
}); | ||
// Parse the response as JSON. | ||
const json = await response.json(); | ||
// Parse the response as JSON. | ||
const json = await response.json(); | ||
// If we get a valid response, save the session_id. | ||
this.sessionId = json.session_id; | ||
this.storage.set({key: AKIO_SESSION_ID_KEY, value: this.sessionId}); | ||
} catch (error) { | ||
this.logger.error(`Failed to init: ${error.message}`); | ||
if (response.status !== 200) { | ||
return this.logger.error(`Failed to init: ${json.error}`); | ||
} | ||
// If we get a valid response, save the session_id. | ||
this.sessionId = json.session_id; | ||
this.storage.set({key: AKIO_SESSION_ID_KEY, value: this.sessionId}); | ||
} | ||
@@ -102,0 +102,0 @@ |
126566
833