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
Categories
- 7.7K All Categories
- 3 Connect
- 919 Connectors
- 244 Workbench
- 477 Transform
- 1.8K Magic ETL
- 60 SQL DataFlows
- 446 Datasets
- 37 Visualize
- 198 Beast Mode
- 2K Charting
- 8 Variables
- 1 Automate
- 348 APIs & Domo Developer
- 82 Apps
- Workflows
- 14 Predict
- 3 Jupyter Workspaces
- 11 R & Python Tiles
- 241 Distribute
- 59 Domo Everywhere
- 241 Scheduled Reports
- 15 Manage
- 36 Governance & Security
- 27 Product Ideas
- 1.1K Ideas Exchange
- Community Forums
- 14 Getting Started
- 1 Community Member Introductions
- 49 Community News
- 18 Event Recordings
- 579 日本支部