I'm getting an error API resolved without sending a response for /api/getPuzzle?puzzleName=00-foo&lang=en, this may result in stalled requests.
for an API handler in NextJS:
export default function handler(req: NextApiRequest, res: NextApiResponse) {
let { puzzleName, lang } = req.query;
const libraryDirectory = path.join(process.cwd(), 'library');
try {
fs.readFile(
libraryDirectory + '/prompts/' + lang + '/' + puzzleName + '.' + lang,
'utf-8',
function (err, data) {
if (err) {
console.log('error in reading from library of prompts fs>>>', err);
res.status(500).send({ success: false });
return;
}
console.log(data);
return res.status(200).send({ data });
}
);
} catch (e) {
console.error('error in fs>>', e);
}
}
I'm not using getserversideprops or anything like that. Thank you.