Node.js Domo Data Set API not returning data...
Hi. I've got my node app to the point where it returns an access token, and as far as I can tell my Node.js request syntax is correct. However, in the response I return I don't see any data. I'm trying to pull a tiny test set I made for this purpose.
Do you see any mistakes with the below code?
```
function get_dataset(access_token) {
options={
host: 'api.domo.com',
accept: 'text/csv',
auth: {
'bearer': access_token
}
}
request.get('https://api.domo.com/v1/datasets/476adbba-3755-4d77-85e1-854177ed9f6b/data?includeHeader=true',options)
.on('error', function(err) {console.log(err);})
.on('response', function(response) {console.log(response);})
}
```
One potential error is the data set ID. I'm taking it out of the data set URL I see in the data set preview page for my data set. Is that the correct place to get this value?
Thanks for any advice,
Mark
Best Answer
-
OK I got it. My error was simply listening for a response. You have to listen for 'data' in the event emitter instead, like so:
function get_dataset(access_token) {
options={
host: 'api.domo.com',
// accept: 'text/csv',
auth: {
'bearer': access_token
}
}
request.get('https://api.domo.com/v1/datasets/476adbba-3755-4d77-85e1-854177ed9f6b/data?includeHeader=true',options)
.on('error', function(err) {console.log(err);})
.on('data', function(data) {console.log(data.toString());})
}2
Answers
-
OK I got it. My error was simply listening for a response. You have to listen for 'data' in the event emitter instead, like so:
function get_dataset(access_token) {
options={
host: 'api.domo.com',
// accept: 'text/csv',
auth: {
'bearer': access_token
}
}
request.get('https://api.domo.com/v1/datasets/476adbba-3755-4d77-85e1-854177ed9f6b/data?includeHeader=true',options)
.on('error', function(err) {console.log(err);})
.on('data', function(data) {console.log(data.toString());})
}2
Categories
- 10.5K All Categories
- 8 Connect
- 918 Connectors
- 250 Workbench
- 473 Transform
- 1.7K Magic ETL
- 69 SQL DataFlows
- 478 Datasets
- 208 Visualize
- 257 Beast Mode
- 2.1K Charting
- 12 Variables
- 18 Automate
- 355 APIs & Domo Developer
- 89 Apps
- 3 Workflows
- 20 Predict
- 5 Jupyter Workspaces
- 15 R & Python Tiles
- 247 Distribute
- 63 Domo Everywhere
- 243 Scheduled Reports
- 21 Manage
- 42 Governance & Security
- 183 Product Ideas
- 1.2K Ideas Exchange
- 11 Community Forums
- 27 Getting Started
- 14 Community Member Introductions
- 55 Community News
- 4.5K Archive