Preserve types in custom useFetch composable?
Probably just missing typescript knowledge... my custom fetch composable doesn't give me the type hints for the requested route while useFetch does that.
8 Replies
Hi there, you can assign Parameters[0] to be your url type, which gives you the hints:
Mhm... It's more about the result of that $fetch
(Just noticed I forgot the screenshots)
I think I got it:
(well, partially. Signature doesn't seem to be fully compatible)
Just saw your messages, yeah that would have been the way I would have gone too
I kept trying, with no success. Something is always off π
sorry! That was accidental π
@Fabian B. - sometimes it can be simple.
π True, though
$fetch.create
does not have the same methods such as $fetch
, but if it works for your case than it's perfect!At least it managed to keep the type information, of the fetched routes - which makes me very happy π