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
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 292 Workbench
- 4 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 95 SQL DataFlows
- 600 Datasets
- 2.1K Magic ETL
- 3.7K Visualize
- 2.4K Charting
- 685 Beast Mode
- 43 App Studio
- 38 Variables
- 655 Automate
- 170 Apps
- 438 APIs & Domo Developer
- 42 Workflows
- 5 DomoAI
- 32 Predict
- 12 Jupyter Workspaces
- 20 R & Python Tiles
- 384 Distribute
- 110 Domo Everywhere
- 268 Scheduled Reports
- 6 Software Integrations
- 111 Manage
- 108 Governance & Security
- 8 Domo University
- 25 Product Releases
- Community Forums
- 39 Getting Started
- 29 Community Member Introductions
- 98 Community Announcements
- Domo Community Gallery
- 4.8K Archive