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

299
Vistas
I'm trying to get a token from API login, but I get an Object null prototype

I am implementing API login with node js and javascript. I'm trying to get a token, but the console says Object: null prototype as shown below.

  [Symbol(Response internals)]: {
    url: 'https://URL(sensitive information)',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

Below is my code.

export const startKakaoLogin = (req, res) => {
  const baseUrl = "https://kauth.kakao.com/oauth/authorize?";
  const config = {
    client_id: process.env.KA_ID,
    redirect_uri: process.env.KA_RE,
    response_type: "code",
    prompt: "login",
  };
  const params = new URLSearchParams(config).toString();
  const finalUrl = `${baseUrl}&${params}`;
  return res.redirect(finalUrl);
};


export const finishKakaoLogin = async (req, res) => {
  const baseUrl = "https://kauth.kakao.com/oauth/token";
  const config = {
    grant_type: "authorization_code",
    client_id: process.env.KA_ID,
    redirect_uri: process.env.KA_RE,
    code: req.query.code,
  };
  const params = new URLSearchParams(config).toString();
  const finalUrl = `${baseUrl}&${params}`;
  const tokenRequest = await fetch(finalUrl, {
    method: "POST",
    headers: {
      Accept: "application/x-www-form-urlencoded;charset=utf-8",
    },
    body: finalUrl,
  });
  console.log(tokenRequest);
};

Additionally, In the reference, 'curl' was used, but I used 'fetch', did I do something wrong?

POST /oauth/token HTTP/1.1
Host: kauth.kakao.com
Content-type: application/x-www-form-urlencoded;charset=utf-8

curl -v -X POST "https://kauth.kakao.com/oauth/token" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d "grant_type=authorization_code" \
 -d "client_id=${REST_API_KEY}" \
 --data-urlencode "redirect_uri=${REDIRECT_URI}" \
 -d "code=${AUTHORIZE_CODE}"
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

What are you expecting to get from the endpoint? You're just logging the Response object right now and are seeing a representation of its internals.

To get e.g. the text from the response body, you'll need to parse it too, here with Response#text():

const text = await tokenRequest.text();
console.log(text);

If you're looking for JSON, then use Response#json().

const data = await tokenRequest.json();
console.log(data);

Be sure to check that the response's error code is what you expect, though, with e.g. tokenRequest.ok.

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