Cant get data from json

Every time I try and get any data from collection.entries i get an Undefined error. I have tried to get the data with collection.entires[1].data and it errors, attempting to define the variables leads to errors

what am I doing wrong?

import fetch from ‘cross-fetch’;
fetch(‘https://’, {
method: ‘post’,
headers: { ‘Content-Type’: ‘application/json’ },
body: JSON.stringify({

    filter: { '_id': { $in: [1] } },
    populate: 1, // resolve linked collection items
})

})

.then(res => res.json())
.then(collection => console.log(collection.entries[1].data));

Cockpit doesn’t use numeric ids, so filter: { '_id': { $in: [1] } }, won’t work.
This should work: filter: {"_id": "5dd81cc0333862174800038e"},.

When you resolve the data, try
.then(data => console.log(data.entries[1]));

I didn’t test the code above, but I hope, the basic concept gets a bit clearer.

PS: You can use fenced code blocks if you encapsulate your code in three backticks

```
JSON.stringify({
  "filter": "..."
}
```