Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
userId is not defined

So i managed to get username from a link but im unsure of how to actually get the userid back. I want it so when it to say the username which works perfectly, but down in thumbnail when i try to fetch the userId it comes up as "userId is not defined". I'm it sure what the solution is but I want to keep both userId and username. here is my code!

const getUsername = userId => new Promise(resolve => {
    fetch('https://users.roblox.com/v1/users/' + userId)
    .then(res => res.json())
    .then(body => resolve(body.name || 'Unknown'))
    .catch(() => resolve('Unknown'))
})
            (async () => {
                const username = await getUsername(nextInQueue.offers[0].userId);
                consola.success(`[${username}] has ok items`)
                
                fetch(config.webhook, {
                    method: 'POST',
                    headers: {
                        'content-type': 'application/json'
                    },
                    body: JSON.stringify({
                        "content": null,
                        "embeds": [
                            {
                                "title": ":tada: Trade sent to: " + username + " :tada:",
                                "color": 28420,
                                "fields": [
                                    {
                                        "name": "Cool Items:",
                                        "value": itemNameList.join('\n')
                                    },
                                    {
                                        "name": "Okay items:",
                                        "value": toreceiveList.join('\n')
                                    }
                                ],
                                "author": {
                                  "name": "Expoorttoo",
                                  "icon_url": "https://i.pinimg.com/736x/4b/69/74/4b6974aef5d96580140ef2686072af3f.jpg"
                                },
                                "footer": {
                                    "text": Sentto.toLocaleString() + " sent & " + tradeQueue.length.toLocaleString() + " set in queue"
                                },
                                "thumbnail": {
                                    "url": "https://www.roblox.com/headshot-thumbnail/image?userId=" + userId + "&width=420&height=420&format=png"
                                }
                            }
                        ]
                    })
                })
            })().catch();
        }

oh yeah by the way its a webhook which it sends to on discord. It works without thumbnail but doesnt work with the thumbnail saying userid.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are missing

const userId = nextInQueue.offers[0].userId;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda