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

81
Vistas
Discord api get guild

I'm trying to fetch my guild info from discord API

fetch('https://discord.com/api/guilds/772037458996101140', {
            headers: {
                authorization: 'bot Nzc******zNjYzOTAz.GPwhCV.rhIcH****5R8ZS-cIo4MjPcBVxO6wYsUXhY'
            },
        })
            .then(result => result.json())
            .then(response => {
                console.log(response);
            })
            .catch(console.error)

only reciving 401 (unauthorized)

i tried changing "bot" to "BOT", "Bot", "Bearer" and doing authorization using access token from Oauth2

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The problem lies in how the Authorization header has been specified. The correct way specify headers would be:


fetch('https://discord.com/api/guilds/772037458996101140', {
            withCredentials: true,
            credentials: 'include',
            headers: {
            'Authorization': 'bot Nzc******zNjYzOTAz.GPwhCV.rhIcH****5R8ZS-cIo4MjPcBVxO6wYsUXhY',
            },
        })
            .then(result => result.json())
            .then(response => {
                console.log(response);
            })
            .catch(console.error)

Hope this helps.

Edit

Also added crendentials and withCredentials based on this answer.

about 4 years ago · Santiago Trujillo Denunciar

0

I was sending http request from front-end and when i moved it to back-end or just used python test file it worked using : Authorization: 'Bot <TOKEN>'

not sure why but it works how it should mby somebody can explain ?

about 4 years ago · Santiago Trujillo 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