Nenad Novakovic
Nenad Novakovic
NNuxt
Created by Nenad Novakovic on 6/20/2024 in #❓・help
Get return type from api route?
Ah took some time to find it. Leaving it here, as it works fine, but maybe someone from core contribs can collaborate if this is the way or there's another approach:
import type { InternalApi } from 'nitropack'
type ApiResponse = InternalApi['/api/example']['get']
import type { InternalApi } from 'nitropack'
type ApiResponse = InternalApi['/api/example']['get']
6 replies
NNuxt
Created by Nenad Novakovic on 5/27/2024 in #❓・help
Read files in API route, fails on Vercel
Yea, I tried that before the rewrite too. But it was not convenient for me, because one of my endpoints indeed needed to go through all as directories were parameters and filenames were ids. If you know what I mean... And with this hook, it's not not possible to list all, without knowing the path and filename.
5 replies
NNuxt
Created by Nenad Novakovic on 5/27/2024 in #❓・help
Read files in API route, fails on Vercel
Seems like it's unresolvable. Spent all day trying to figure it out with different approaches and nothing worked. Had to rewrite all the logic and use Vercel's Postgres + Drizzle.
5 replies
NNuxt
Created by Nenad Novakovic on 5/27/2024 in #❓・help
Read files in API route, fails on Vercel
process.cwd() returns:
[
"chunks",
"index.mjs",
"index.mjs.map",
"node_modules",
"package.json"
]
[
"chunks",
"index.mjs",
"index.mjs.map",
"node_modules",
"package.json"
]
So no wonder it cannot read from public dir. How to make it read from public directory tho?
5 replies
NNuxt
Created by Nenad Novakovic on 4/5/2024 in #❓・help
How to infer the type from `useAsyncData`?
Would you look at that. Completely forgot about NonNullable last night. Thanks a lot @Fabian B.
8 replies
NNuxt
Created by Nenad Novakovic on 4/5/2024 in #❓・help
How to infer the type from `useAsyncData`?
Tried [number] and tried [0] and then Type error comes up:
Property '0' does not exist on type 'Simplify<SerializeObject<{ id: number; price: number; checkoutId: string | undefined; recurrence: string; label: string; description: string; }>[] | undefined> | null'.
Property '0' does not exist on type 'Simplify<SerializeObject<{ id: number; price: number; checkoutId: string | undefined; recurrence: string; label: string; description: string; }>[] | undefined> | null'.
8 replies