trpc-nuxt icon indicating copy to clipboard operation
trpc-nuxt copied to clipboard

fix: don't discard error in client

Open littlejon85 opened this issue 2 years ago • 1 comments

This resolves #9
The main issue is that the client tries to use serverError from useState and ignores the error from useAsyncData.
I'm not exactly sure how serverError is populated. I assume it has something to do with SSR. However in case without SSR the returned error is always null.

The proposed solution is to use the error from useAsyncData as initial value for useState.

const serverError = useState<TError | null>(`error-${key}`, () => error.value)

littlejon85 avatar Oct 11 '22 12:10 littlejon85

I'll test this locally. Thanks!

wobsoriano avatar Oct 14 '22 07:10 wobsoriano