I am trying to fetch some data from my backend to my frontend. However, in doing so, the data I receive looks something like:
[
0: {"date": "2023-01-01", "id": "2023-01-01_0_GB", "product": "Snickers"},
1: {"date": "2023-01-02", "id": "2023-01-02_0_GB", "product": "Bounty"},
2: {"date": "2023-01-03", "id": "2023-01-03_0_GB", "product": "Twix"},
...
]
As you can see, the key is just numbers from 0 and up. But I would actually like the key do be the id
of each dict.
From my backend I return the data by:
return DataResponse(
df=df.to_dict(orient="records"),
)
And it doesn't matter if I use reset_index()
or not. If I do, that data will not be a part of the data received in the frontend, hence, I always use reset_index()
so I have everything.
So yeah, how do I do that?