N
NuxtAlejandro Mery

FetchError type

I've seen import type { FetchError } from 'ofetch', what what's the correct module when handling useFetch() errors?
P
pyplacca14d ago
Usually “#imports” or “#app” would have what you’d need from your nuxt app
AM
Alejandro Mery14d ago
I just tried both, no luck 😦 and using ofetch feels dirty
P
pyplacca13d ago
It seems neither fetch nor ofetch exports it You can still retrieve the type by doing something like:
type FetchError = ReturnType<typeof useFetch<{}>>[‘error’][‘value’]
type FetchError = ReturnType<typeof useFetch<{}>>[‘error’][‘value’]
replace {} with your data’s type
AM
Alejandro Mery13d ago
thank you 🙂 would this qualify as a bug to report?
P
pyplacca13d ago
Oh no. An improvement, sure
L
l422y13d ago
should be fine with import { FetchError } from 'ofetch'
P
pyplacca13d ago
ofetch doesn’t export the FetchError, or does it? Oh it does 😅 @L422Y @Alejandro Mery
L
l422y13d ago
it's a class not a type, so typeof FetchError is maybe what we're looking for if you need a type:)
P
pyplacca13d ago
Just FetchError works fine @L422Y Using typeof doesn’t yield what you’d expect @Alejandro Mery, this should be easier (what @L422Y said) https://discord.com/channels/473401852243869706/1224809697689862156/1224827570285973655
L
l422y13d ago
yeah it's "function" 🙂
AM
Alejandro Mery13d ago
Thank you @pyplacca @L422Y
AM
Alejandro Mery13d ago
GitHub
FetchError type · Issue #26628 · nuxt/nuxt
Describe the feature import type { FetchError } from 'ofetch' is generally used to type useFetch() errors, but shouldn't that be exported by #imports or #app? https://discord.com/channe...
P
pyplacca13d ago
@Alejandro Mery, you needn't create an issue 😅
AM
Alejandro Mery13d ago
feature request 😅 in case someone searches for FetchError there
P
pyplacca13d ago
import import type { FetchError } from 'ofetch' won't work because it's a class like @L422Y mentioned
AM
Alejandro Mery13d ago
should I delete it? comment it please 🙂
P
pyplacca13d ago
the import statement should've instead been import { FetchError } from 'ofetch'
AM
Alejandro Mery13d ago
I'll edit the issue after you correct me there :p
P
pyplacca13d ago
sure
AM
Alejandro Mery13d ago
I'll close this now 🙂 thank you both!
Want results from more Discord servers?
Add your server
More Posts
How to import functions in a .vue component from a .js file?import { myfunctions} from "/js/stats.js" doesnt work for me: Error 500 __vite_ssr_import_7__.defauskeleton does not work on dynamic routesguys, can anyone help me? the skeleton is appearing on the main page but on the page where the produhow to generate static HTML pages just for some of the routesI'm trying to generate 4 static HTML pages from a huge list of routes that the app has But I only seUDashboardPanel footer (@nuxt/ui-pro)I'm trying to put a footer on the main (`grow` enabled) panel but I can't get the css right. in the useRuntimeConfig() is returning undefined valuesIn my `.env` file I have something like this: ``` NUXT_PUBLIC_LOGIN_DOMAINS="domain1.com,domain2.co@nuxt/eslint autofix?when using `@nuxt/eslint` instead of the old `@nuxtjs/eslint-module` how does one enable autofix? `Check whether any page has fully mounted from the root App.vueSome of my pages have a ```ts definePageMeta({ hideSidebar: true }) ``` which sets the `hideSidebarGetting error "Component is already mounted" when using "useFetch()" and changing route.I am getting the error in my console: ``` [nuxt] [useFetch] Component is already mounted, please uHelp with postinstall: sh: nuxt: not foundHello, I need help with a concern I have regarding the `postinstall` script that runs `nuxt prepare`Types errors in Storybook and tests after upgrade nuxt to 3.11.0Hello there! I upgrade the nuxt version from 3.9.0 to 3.11.0, but now when I run `npm run tsc` I geNuxt eslint module helpI'm joining a new nuxt project that have vue3 eslint plugin, does the Nuxt Eslint Module replace theTailwind CSS errorKeep getting this error in my Nuxt project on saveRouting to another page leads to null parent node errorWhen converting a Vue app to Nuxt and after following directory and layout structures, routing leadsi18n doesn't work with 3.11I already reported a bug for it, just wanted to post for posterity. When using `getRoutseBaseName`,eslint vs typescript 5.45.4.3 is being pulled by nuxt but eslint doesn't like it even if I explictly install the latest `vituseNuxtApp doesn't have my custom pluginsThere are no my custom plugins inside the useNuxtApp hook, they just don't show up.Middleware called 3 times instead of 2 ? (stackblitz reproduction)Can you tell me why my middleware is called 3 times ? https://stackblitz.com/edit/github-3enzca-ixdadd class to default root div __nuxtHi, I'm migrating a VUE 3 SSR project to Nuxt 3 and saw that Nuxt adds a rot div that we don't have Maximum call stack size exceededGetting the below error after updating my nuxt version from ('^3.5.1') to ('^3.11.1). and it will brModule creation questionI'm working on a module and I need to install another module that can import/install other modules o