Help with API as data source in Table. The selected data source could not be converted to an array

My gold is to present my data in a table with multiselecting
ReTool: Self-hosted _ ver 3.114.3

Issue: The Table component will not show my data from the API response. I get this message:
"The selected data source could not be converted to an array"

I have tested:
Data source: query96
Data source (Fx): {{ formatDataAsArray(query96.data) }}
Data source (Fx): {{ formatDataAsArray(query96.data.hits.hits) }}
Data source (Fx): {{ formatDataAsArray(query96.data.hits.hits._source) }}

Query96
API GET
Body: RAW

  {
     "query": {
      "match_all": {}
    }
}

Response:

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "retool_even",
        "_id": "yTPjopUBwtqmWe9eXk52",
        "_score": 1,
        "_source": {
          "SourceID": 22,
          "ProductID": 2164557,
	  "ProductCreateDate": "2009-06-08T15:56:38",
          "ProductCreatedBy": ""
        }
      }
    ]
  }
}

Is there a way to present the data in a table component?

Hey there @Thore,

Try adding square brackets, i.e. [ {{ query96.data.hits }} ] . This is what I get:

This solve the message, Thanks.

But it do not solve listing of the data I'm are interested in.

I added data Source (FX): [ {{ query96.data.hits.hits}} ]

I'm traying [ {{ query96.data.hits.hits._source}} ]

This returns null

But as you can see the information I whant to list is in the Source column.

Can it be that the name is "_source"?

{
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 71,
      "relation": "eq"
    },
    "max_score": 16.200567,
    "hits": [
      {
        "_index": "retool_even",
        "_id": "-jXlopUBwtqmWe9eJx6M",
        "_score": 16.200567,
        "_source": {
          "SourceID": 22,
          "ProductID": 2335804,

any Idees?

Try adding the below into your query96's transform data section:

return data.hits.hits.map(hit => hit._source);
2 Likes

This is working. Many thanks for all your help.

1 Like