wobsoriano / trpc-nuxt

End-to-end typesafe APIs in Nuxt applications.
trpc-nuxt.vercel.app
MIT License
687 stars 39 forks source link

How to use useQuery with a transform function #78

Closed kouts closed 1 year ago

kouts commented 1 year ago

Thanks for this great library. I have a question regarding the usage of useQuery with a transform function. I'm using it like this:

<script setup lang="ts">
const { $client } = useNuxtApp()

const { data, pending } = await $client.admin.getContent.useQuery(undefined, {
  lazy: true,
  transform(value) {
    return value
  }
})
</script>

but I get a Typescript error on the transform function image

what am I missing?

mlbiche commented 1 year ago

It's been a while and I hope you have solved your issue, but I think it should be

transform: (value) => {
  return value
}
kouts commented 1 year ago

Thanks @mlbiche