Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constants mismatch in Transport.js #10

Open
sstradling opened this issue Sep 22, 2017 · 1 comment
Open

Constants mismatch in Transport.js #10

sstradling opened this issue Sep 22, 2017 · 1 comment

Comments

@sstradling
Copy link

I'm getting the following error when attempting to call .datasets.list:

{ Error: Unable to GET /v1/datasets for Dataset at RequestException (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Errors.js:5:9) at request.catch (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Transport.js:20:24) at process._tickCallback (internal/process/next_tick.js:109:7) method: 'GET', type: 'Dataset', path: '/v1/datasets', error: TypeError: Constants_1.API_SCOPE[s].toLowerCase is not a function at scope.scopes.map.s (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Transport.js:76:46) at Array.map (native) at Transport.renewAccessToken (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Transport.js:72:14) at Transport.retryRequest (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Transport.js:105:25) at rp.catch.err (/Users/sethstradling/Documents/Development/cerberus/node_modules/domo-sdk/dist/common/Transport.js:101:32) at process._tickCallback (internal/process/next_tick.js:109:7) }

It appears that when Transport.js is processing/mapping scopes, the generated constants.API_SCOPE looks like:
{ '0': 'USER', '1': 'DATA', USER: 0, DATA: 1 } ,
and since I'm passing 'USER', the function is attempting to pass 0 to .toLowerCase().

Not sure why API_SCOPE is getting interpreted that way.

@walexnelson
Copy link
Contributor

@sstradling

The client is expecting an array of enums which have been defined in the constants

The examples demonstrate how to use them

const { DomoClient } = require('../dist');
const { API_SCOPE } = require('../dist/common/Constants');

const clientId = process.env.DOMO_CLIENT_ID;
const clientSecret = process.env.DOMO_CLIENT_SECRET;
const host = 'api.domo.com';

// use the values defined in the enum
const scopes = [API_SCOPE.DATA];

const domo = new DomoClient(clientId, clientSecret, scopes, host);

We can support an array of strings too if that's preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants