Next.js Discord

Discord Forum

Where to put util functions

Answered
Mudi posted this in #help-forum
Open in Discord
MudiOP
Hi, quick question. I want to make a function that read/write to json file

Where to put the function file in app structure, i added thejson file and the ts file in src/util but didn't work.
Answered by Mudi
fixed it, used
fs.readFile('./src/utils/teams.json');
View full answer

6 Replies

@gin code?
MudiOP
something simple as this
@Mudi something simple as this
check if the file is found first
and also make sure you are in the correct dr
dir*
@gin and also make sure you are in the correct dr
MudiOP
fixed it, used
fs.readFile('./src/utils/teams.json');
Answer