Display query result in a table

by Sandy Allibert   Last Updated June 12, 2019 08:22 AM

How can I retrieve the result of a SQL query from a source?

I would like to create a dynamic table that displays the result of a query.

 const source= new carto.source.SQL('SELECT cartodb_id, country, pop, the_geom_webmercator, the_geom FROM country');

const layer= new carto.layer.Layer(source, style, {
    featureOverColumns: ['cartodb_id', 'country', 'pop', 'the_geom']

layer.on('featureOver', data => {

 source.setQuery('SELECT * FROM country WHERE pop > 10000')
        .catch(cartoError => {
        .then(success => {
            //Display result
            console.log(success); //undefined

I can't get the result back. setQuery returns a Promise object, but it undefined.

I guess I miss something... any idea ?

Related Questions