Added API endpoints for navbar and themes
This commit is contained in:
parent
fd298c90d1
commit
bb76b00506
4 changed files with 102 additions and 0 deletions
pages/api/v1
15
pages/api/v1/navbar.tsx
Normal file
15
pages/api/v1/navbar.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import fsPromises from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
export default async function Navbar(req: any, res: any) {
|
||||
try {
|
||||
const filePath = path.join(process.cwd(), '/public/data/navbar.json')
|
||||
const jsonData = await fsPromises.readFile(filePath)
|
||||
const data = JSON.parse(jsonData.toString())
|
||||
res.status(200).json(data)
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error)
|
||||
res.status(500).json({error: 'Error reading data'})
|
||||
}
|
||||
}
|
15
pages/api/v1/themes.tsx
Normal file
15
pages/api/v1/themes.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import fsPromises from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
export default async function Navbar(req: any, res: any) {
|
||||
try {
|
||||
const filePath = path.join(process.cwd(), '/public/data/themes.json')
|
||||
const jsonData = await fsPromises.readFile(filePath)
|
||||
const data = JSON.parse(jsonData.toString())
|
||||
res.status(200).json(data)
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error)
|
||||
res.status(500).json({error: 'Error reading data'})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue