Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

292
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!