Next.js Discord

Discord Forum

Imported function is undefined in a dynamic route

Answered
Southern yellowjacket posted this in #help-forum
Open in Discord
Southern yellowjacketOP
So I am trying to import this function from my api routes which is supposed to build my data path and then extract it but the imported files are rendered undefined and throws an error saying the function doesnt exist.
Answered by Southern yellowjacket
I commented that code that was giving me error, then re ran the development and it started throwing the error that 'fs' cant be resolved, probably because fs is only allowed server side, then I remove the comments to resolve this and it started working
View full answer

6 Replies

Southern yellowjacketOP
These are the functions I am exporting
I am importing them here in a dynamic route
[employeeId]
I am calling those functions in a
getServerSideProps
function
Southern yellowjacketOP
I commented that code that was giving me error, then re ran the development and it started throwing the error that 'fs' cant be resolved, probably because fs is only allowed server side, then I remove the comments to resolve this and it started working
Answer
Southern yellowjacketOP
I dont get it but it works now :this_is_fine: