getting a server response without metadata (config, header, request, status)

When I make a request like this (screenshot1) I always get a nested data object along side config, header, request, status, statustext (screenshot2) That has been fine so far, but now that I have a paginated response that I'm getting via React Query useInfiniteQuery(), I get multiple data objects nested within each other on subsequent pages (screenshot3) Perhaps Axios is related to the issue here? On postman I only get the data itself (screenshot4) I would be greateful, if you could point me in a direction.
11 Replies
.j0hannes
.j0hannes2y ago
rocawear
rocawear2y ago
I always do like if dont need other than the data part:
const data = await(await axios.get(path)).data
const data = await(await axios.get(path)).data
.j0hannes
.j0hannes2y ago
then I get Property 'data' does not exist on type 'Promise<AxiosResponse<any, any>>'
Matvey
Matvey2y ago
you don't need two awaits with axios
const { data } = await axios.get(path);
return data;
const { data } = await axios.get(path);
return data;
.j0hannes
.j0hannes2y ago
Matvey
Matvey2y ago
you forgot await await axios.get(...)
.j0hannes
.j0hannes2y ago
do I still need that when using React Query?
Matvey
Matvey2y ago
yes
.j0hannes
.j0hannes2y ago
I still have the underlying issue: for subsequent pages, there is another data object
.j0hannes
.j0hannes2y ago
this must be something related to my React Query implementation no the issue is on my backend
Matvey
Matvey2y ago
you need to rename items to pages i think
Want results from more Discord servers?
Add your server