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

  • Unknown
    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());})
            
    }

Answers

  • Unknown
    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());})
            
    }

This discussion has been closed.