async bois!

This commit is contained in:
nannal 2020-02-16 10:53:52 +02:00
parent 80e7b59fe3
commit 2e5f7eafdc
2 changed files with 11 additions and 12 deletions

View File

@ -20,16 +20,17 @@ app.use(bodyParser.json(),function (req, res, next) {
app.get('/lobby/list' , async function (req, res) { app.get('/lobby/list' , async function (req, res) {
lobby.list().then(r => { lobby.list().then(r => {
console.log(r) console.log(r)
res.send(JSON.stringify({gamesArr: r }))
}) })
console.log()
result=""
res.send(JSON.stringify({gamesArr: result }))
}) })
//get game details //get game details
app.get('/lobby/details', function (req, res) { app.get('/lobby/details/:gameID', function (req, res) {
let obj=req.body let obj=req.body
res.send(lobby.details(obj.gameID)) lobby.details(obj.gameID).then(r => {
res.send(JSON.stringify(r))
})
}) })
//post register player //post register player

View File

@ -3,14 +3,12 @@ const uuidv4 = require('uuid/v4');
var lobby={ var lobby={
list: async () => { list: async () => {
mongo.get("embezzle","gamelist",{}).then(result => { result = await mongo.get("embezzle","gamelist",{})
return(result) return(result)
})
}, },
details: (gameID) => { details: async (gameID) => {
mongo.get("embezzle","gamelist",{"gameID":gameID}).then(result => { result = await mongo.get("embezzle","gamelist",{"gameID":gameID})
return (result) return (result)
})
}, },
register: (name) => { register: (name) => {
id=uuidv4() id=uuidv4()