From fa9cb5347023fee3c9a5b74f70a23592313b0eb5 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Sun, 20 Sep 2020 11:38:29 -0400 Subject: [PATCH] Fix issue with code vs status_code --- lib/api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api.js b/lib/api.js index 270d810..04af628 100644 --- a/lib/api.js +++ b/lib/api.js @@ -20,7 +20,7 @@ const internalHeaderKey = 'x-user-session-token' const visitorSessionKey = 'tncpw_session' // Current version for requests from the API -const pkgVersion = 'v0.1.76' +const pkgVersion = 'v0.1.77' const apiVersion = 'v1' // getOptions is a factory for axios default options @@ -45,6 +45,7 @@ function getOptions (t, useCustomSessionToken = '') { } // blockBrowser will block request from firing if loaded in web browser +// todo: change this to detect node instead of browser: https://github.com/flexdinesh/browser-or-node/blob/master/src/index.js function blockBrowser () { if (typeof window !== 'undefined') { throw Error('cannot do this request in a web browser') } } @@ -1286,7 +1287,7 @@ module.exports = { response.data['exists'] = true resolve(response.data) } catch (e) { - if (typeof e.response !== 'undefined' && e.response.data.code === 404) { + if (typeof e.response !== 'undefined' && e.response.data.status_code === 404) { resolve({ exists: false }) return }