를 사용 jsonwebtoken``와 토큰 만료를 얻을 수 있습니다. 타이프는 exp
재산에 대한 오류를 던지고, 나는 그것들을 해결하는 방법을 아주 확실하지 않다 :는 어떻게 토큰을 디코딩 <code>jsonwebtoken</code>를 사용하고, 나는 만료 날짜를 얻으려고 타이프 라이터
import jwt from 'jsonwebtoken'
const tokenBase64 = 'ey...' /* some valid token */
const token = jwt.decode(tokenBase64)
const tokenExpirationDate = token.exp
// ^^^
// Property 'exp' does not exist on type 'string | object'. Property 'exp' does not exist on type 'string'.
내가 @types/jsonwebtoken
를 설치하고, token
을 캐스팅 토큰 유형 보았지만 아무것도 발견하지 않았다. 제안?
.tsconfig 사용
: 제가 var jwt = require('jsonwebtoken');
으로 라인 import jwt from 'jsonwebtoken'
를 사용할 때 동일한 오류 메시지를 가지고
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"jsx": "Preserve",
"moduleResolution": "Node",
"module": "ESNext",
"sourceMap": true,
"removeComments": true,
"allowSyntheticDefaultImports": true,
"target": "ESNext"
}
}
수 있습니다 당신은 pls. 내 솔루션이 내게 도움이되는지 알려주세요. 그렇다면 내 대답을 수락하십시오. 미리 감사드립니다. 귀하의 질문에 업데이트 – jps