Ragura
Is there a recommended way to start a nuxt project ?
There's a few starter templates available here: https://nuxt.new/
However, Nuxt isn't difficult to set up incrementally. You basically create the folders you need when you need them. As for modules such as ESLinst, just browse those on nuxt.com or use the devtools to install them. Most of them are zero-config or close to.
You can also use the VSCode extension Nuxtr to help you with creating the right folder structure.
2 replies
what’s the difference between antfu/eslint config vs the eslint plugin ?
Antfu's ESLint config includes a lot more rules than the standard Nuxt ESLint config. I use it for all my applications. It really comes down to how opinionated you want your rules to get. Of course, you can always disable rules you don't like separately.
2 replies
How to assign a middleware to custom routes?
You can add middleware programmatically with the
pages:extend
hook. https://nuxt.com/docs/guide/directory-structure/middleware#setting-middleware-at-build-time
This usage is specifically called out with custom routing here:
https://nuxt.com/docs/guide/recipes/custom-routing#router-config6 replies
Get return type from api route?
Interesting that you can get the types that way, thanks for following up on your own issue 🙂
I wonder though if it wouldn't be better to create a type/interface inside the API route (or a shared types folder) and explicitly make sure the return value is of that type. Then you wouldn't have to look up the type anywhere else and could import it.
6 replies
`$fetch` error handling.
The above is how I'm handling it now too. Made a separate function
parseError
to do the type checking so I wouldn't have to put the boilerplate there all the time, but this is the recommended way to handle errors in a try/catch regardless of using Nuxt or not. You should double check which fields you want from the object by inspecting the FetchError
type (such as statusMessage
).3 replies