How do i get the filename in /api/anyApi file ?? #23692
Unanswered
sahilrajput03
asked this question in
Help
Replies: 2 comments 6 replies
-
Hi, what's wrong with |
Beta Was this translation helpful? Give feedback.
6 replies
-
I know this comment section is old, but for me. I use Next.JS + Vercel. With this structure on (app/api/):
When calling the API from the client side (app/exercises/page.ts), I get this. Litterally can't get the name bc of webpack's dynamic naming hasing or something i suppose console.log(__filename) // C:\Users\ptdrr\Desktop\Projets\bimowy\.next\server\chunks\[root of the server]__47d6b187._.js
console.log(path.basename(__filename)) // [root of the server]__47d6b187._.js
console.log(path.parse(__filename))
// {
// root: 'C:\\',
// dir: 'C:\\Users\\ptdrr\\Desktop\\Projets\\bimowy\\.next\\server\\chunks',
// base: '[root of the server]__47d6b187._.js',
// ext: '.js',
// name: '[root of the server]__47d6b187._'
// } |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
console.log(__filename) // Output: /index.js
What is the work i need to do here..?
Beta Was this translation helpful? Give feedback.
All reactions