0

I am calling the Tempo API to get timelogs for multiple users. My function loops through rows in a table and calls the API for each, returning an array of objects with nested arrays of 'results' - which is what I need to access.

The data returned is in this structure: enter image description here

I want to just have an array of [results] so I can access the relevant keys I need and set each in a row of a table.

I have checked similar posts and tried suggestions but can't find one that works. Any help greatly appreciated!

Nick

I've tried this suggested approach:

var flattened = [].concat.apply({}, data);

However I still get back the [results] nested inside array [0].results [1].results etc

Also reviewed this post but can't find a solution that works for me on this:

text

  • You can use [`.flatMap()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap) (see examples from the link above your question on how to use it) – Nick Parsons Jul 02 '23 at 03:31
  • 1
    Thanks so much @NickParsons - const res = arr.flatMap(({ results }) => results) works perfectly. – nickausaus Jul 02 '23 at 04:21

0 Answers0