Skip to content

Commit

Permalink
Lint fixes, added check for node when initializing
Browse files Browse the repository at this point in the history
  • Loading branch information
icellan committed Apr 23, 2021
1 parent 34418d2 commit 855ccc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/api-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const axios = require('axios');// .default (@mrz what does this affect?)
const axios = require('axios'); // .default (@mrz what does this affect?)

export const tonicAxios = axios.create();

// Used internally for communication from req=>resp in axios
Expand All @@ -14,16 +15,16 @@ export const getOptions = function (t, useCustomSessionToken = '') {
const defaultOptions = {
withCredentials: true,
headers: {
'api_key': t.config.apiKey,
api_key: t.config.apiKey,
'User-Agent': 'tonicpow-js ' + pkgVersion,
},
};

// Detect custom headers
if (t.session.customHeaders) {
Object.keys(t.session.customHeaders).forEach((key) => {
defaultOptions.headers[key] = t.session.customHeaders[key];
});
defaultOptions.headers[key] = t.session.customHeaders[key];
});
}

// Set the user session token if set
Expand Down
4 changes: 4 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { createApiClient } from './api-client';
*/
class TonicPow {
constructor(apiKey, options = {}) {
if (!isNode) {
throw new Error('This library only works in node');
}

// Set any defaults
this.session = new Session(options);
this.config = new Config(apiKey, options);
Expand Down

0 comments on commit 855ccc0

Please sign in to comment.