Grafana custom data source plugin showing empty promise object

Hey guys so I have a custom datasource plugin. What im trying to do is make an http request to an outside source for each ‘x’ number of elements inside of a switch statement. After the results I want to add that information to the ‘data’ frame so I can further use that data to be rendered in a table.
My issue is that the value being showed in the table in [object promise]
Here is where it the issue occurs

logs.map(async (log) => {
      switch (log._source.route) {
        case '/heatmap':
          resolveHeatmap(log._source.request_parameters, log._source.entity_ids ,'Geospatial insight').
          then((resolvedEntities) => {
            console.log(resolvedEntities)
             data[0].add({ 
            client: log._source.client_name, 
            allowed_types: log._source.request_types, 
            request_time: log._source.request_time,
            resolved_entities: resolvedEntities })
          });
          break;
        default:
      }

In my grafana table I end up with an empty object of a promise in my ‘resolved_entities’ column.
Screenshot from 2021-09-28 08-41-06

It doesn’t look like your map function is actually returning any values. Does it work if you add a return before the call to resolveHeatmap?

Hey marcus I was able to solve the issue by using .then() inside of my resolveHeatmap function. Thanks for the reply

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.