Typing ref for $fetch
I need to create a ref that is typed for the return value of an api endpoint. I'll be updating it from a button $fetch request. I found this site Nuxt 3 server routes and Typescript that seems to give a good way to do it via an
For instance, I have
Result is typed as such
but userInfo is typed this way
The weird thing is the
apiRef({ route: '/xx', method: 'get', defaultValue: null }) composable but it doesn't seem to be giving me the right typings.For instance, I have
Result is typed as such
but userInfo is typed this way
The weird thing is the
userInfo.value = result does not give a typescript error. But trying to use {{ userInfo.username }} gives 'username' does not exist on ...