Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

0

You are missing

const userId = nextInQueue.offers[0].userId;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda