site/pages/api/games.js
2023-02-22 13:19:10 +05:30

16 lines
No EOL
360 B
JavaScript

export async function getGames() {
let games = await fetch(
'https://editor.sprig.hackclub.com/metadata.json'
).then(res => res.json())
games = games
.sort((a, b) => new Date(b.addedOn) - new Date(a.addedOn))
.slice(0, 4)
return games
}
export default async function Games(req, res) {
const games = await getGames()
res.json(games)
}