This repository has been archived on 2024-08-06. You can view files and clone it, but cannot push or open issues or pull requests.
readyornot/pages/api/[map].tsx

16 lines
563 B
TypeScript
Raw Normal View History

2022-12-03 20:02:18 +00:00
import fsPromises from 'fs/promises'
import path from 'path'
export default async function MapApi(req: any, res: any) {
const { map } = req.query
try {
// get Empire and Game name first to create an EmpireData object
const filePathMap = path.join(process.cwd(), '/public/images/'+map+'/info.json');
const jsonMapData = await fsPromises.readFile(filePathMap);
res.status(200).send(jsonMapData.toString())
}
catch (error) {
console.log(error)
res.status(500).json({error: 'Error reading data'})
}
}