#TypeError: Cannot read properties of undefined (reading 'serverid')

34 messages · Page 1 of 1 (latest)

astral lion
#

TypeError: Cannot read properties of undefined (reading 'serverid')

#
      res.sendFile(__dirname + '/index.html')
      const serverid = req.query.state
  console.log(serverid)
  const server = servers.findOne({serverid:serverid})
const discordServer = await client.guilds.fetch(server.serverid)
proven tiger
#

Code

#

Ok

#

well req.query.state is undefined

#

No wait

#

Dumb brain

#

What line does that correspond to?

proven tiger
astral lion
#

index 56 js const discordServer = await client.guilds.fetch(server.serverid)

proven tiger
#

Atm server is a promise

astral lion
#

so what should i do

#

@proven tiger

proven tiger
#

Put await before the findOne

astral lion
#

oky

#
      res.sendFile(__dirname + '/index.html')
      const serverid = req.query.state
  console.log(serverid)
  await const server = servers.findOne({serverid:serverid})
const discordServer = await client.guilds.fetch(server.serverid)
#

like this?

proven tiger
#

Before the findOne

#

const server = await servers.findOne(…)

livid tulipBOT
astral lion
#

@proven tiger

proven tiger
#

Did you write this code?

astral lion
#

yes

proven tiger
#

I put … so you could fill it in

astral lion
#

look index.js 53

proven tiger
astral lion
#

yes

#

@proven tiger if u want i can give u my vps