diff --git a/src/routes/api/getGameScore.js b/src/routes/api/getGameScore.js index 27abc68..c96a1e5 100644 --- a/src/routes/api/getGameScore.js +++ b/src/routes/api/getGameScore.js @@ -14,14 +14,27 @@ async function main() { const collection = database.collection('gameData'); // Replace with your collection name // Find a single document - const user = await collection.findOne({ userId: 'dsfdfgffgfgeg' }); + // const user = await collection.findOne({ userId: 'dsfdfgffgfgeg' }); + + const { userId, gameName, gameID } = req.body; + const gameData = await collection.findOne({ + userId: userId, + gameName: gameName, + gameID: gameID + }); + + if (gameData) { + res.json({gameData}); + } else { + res.status(404).json({ message: 'Game data not found' }); + } // Output the result - if (user) { - console.log('User found:', user); - } else { - console.log('No user found with the username "john_doe"'); - } + // if (user) { + // console.log('User found:', user); + // } else { + // console.log('No user found with the username "john_doe"'); + // } } catch (error) { console.error('Error connecting to MongoDB or performing query:', error); } finally {