Closed dimasxp closed 4 months ago
There currently is no built-in way to transform the response before caching. Instead, you could just create a composable that transforms the data like this:
export function useUserNames(){
const query = useTRPC().users.list.useQuery()
return {
...query,
data: computed(() => query.data.value?.map(user => user.name))
}
}
There also is a select
query option:
useTRPC().users.list.useQuery(undefined, {
select: (users) => users.map(user => user.name)
})
Got it, thanks for the good examples and this wrapper. very handy and useful 👏
how to transform response before cache ?