mirror of
https://github.com/kevin-DL/commander_league_web.git
synced 2026-01-17 04:24:52 +00:00
Initial commit from Create Next App
This commit is contained in:
17
pages/api/getFood.js
Normal file
17
pages/api/getFood.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { verifyIdToken } from '../../utils/auth/firebaseAdmin'
|
||||
const favoriteFoods = ['pizza', 'burger', 'chips', 'tortilla']
|
||||
|
||||
const getFood = async (req, res) => {
|
||||
const token = req.headers.token
|
||||
|
||||
try {
|
||||
await verifyIdToken(token)
|
||||
return res.status(200).json({
|
||||
food: favoriteFoods[Math.floor(Math.random() * favoriteFoods.length)],
|
||||
})
|
||||
} catch (error) {
|
||||
return res.status(401).send('You are unauthorised')
|
||||
}
|
||||
}
|
||||
|
||||
export default getFood
|
||||
Reference in New Issue
Block a user