프로그래밍/react

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call') at Hmac.CipherBase

한코코 2022. 10. 26. 13:44

로그인을 했을때 jsonwebtoken 라이브러리를 사용해서 토큰을 생성하려고했는데,

토큰은 무사히 생성되었지만, 토큰을 가져와서 디코딩할때 다음과 같은 오류가 생겼다.

//jwt.js
function decodePayload(token) {
  return jwt.verify(token, secretKey, (error, decoded) => {
    if (error) {
      console.log("jwt 에러발생 : ", error.message);
      return;
    } else {
      console.log(decoded); // 유저 정보 object 반환
    }
  });
}

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call') at Hmac.CipherBase

정의되지 않은(undefined) 객체(object)의 속성(property) 값 또는 함수를 읽으려고 하거나 호출하려고 할 때 발생하는 오류다.

잘 살펴보니 인증코드를 가지고 복호화를 하려고하고있었다... 수정함...

 

 

( 참조 블로그 :  https://domdom.tistory.com/entry/%EC%98%A4%EB%A5%98%ED%95%B4%EA%B2%B0-Uncaught-TypeError-Cannot-read-properties-of-null-Uncaught-TypeError-Cannot-read-properties-of-undefined )