T
TanStack3y ago
vicious-gold

Ho to enhance previous response. Now that the on success is not accessible.

I have some data that i get as an array and want to transform and save in the below format.
{
posts: {
'id1: {...},
'id2: {...},
.
.
'id10: {...},
},
page: 1,
limit: 150,
}
{
posts: {
'id1: {...},
'id2: {...},
.
.
'id10: {...},
},
page: 1,
limit: 150,
}
Now on the next page I will receive X next items, but i want to transform them and enhance the existent state so now page is updated, and the posts contains 10 new keys. How do you do this now that the onSuccess is removed from the useQuery
2 Replies
reduced-jade
reduced-jade3y ago
Can't this be done in the select callback? And if this needs to be shared to several "mounting-points" of the query, have you considered putting the parsing inside the queryFn?
vicious-gold
vicious-goldOP3y ago
I figured it out actually, doing things with the queryFn. and accessing the previous response there. Cheers

Did you find this page helpful?