popular games endpoint

This commit is contained in:
Gamebrary 2020-09-15 15:39:03 -07:00
parent 34462ff230
commit 5fe4ce98fb

View file

@ -133,6 +133,33 @@ exports.game = functions.https.onRequest((req, res) => {
.catch((error) => { res.send(error) }); .catch((error) => { res.send(error) });
}); });
exports.popularGames = functions.https.onRequest((req, res) => {
res.set('Access-Control-Allow-Origin', "*")
const data = `fields
name,
screenshots.image_id,
popularity,
platforms.name;
limit 50;
where platforms = (48, 49, 130, 167, 169);
sort popularity desc;
`;
axios({
url: 'https://api-v3.igdb.com/games',
method: 'POST',
headers: {
'Accept': 'application/json',
'user-key': functions.config().igdbv3.key,
},
data,
})
.then(({ data }) => { res.status(200).send(data) })
.catch((error) => { res.send(error) });
});
exports.email = functions.https.onRequest((req, res) => { exports.email = functions.https.onRequest((req, res) => {
res.set('Access-Control-Allow-Origin', "*") res.set('Access-Control-Allow-Origin', "*")