Having issues while trying to compile a typescript file as the compiler is throwing an error message:
Error: TS2339 - The property 'payload' does not exist on type 'string | object'.
Property 'payload' does not exist on type 'string'.
Here is the problematic code:
decode(token: string): any {
const decodedJWT = jwt.decode(token, { complete: true });
const issuer = decodedJWT.payload.iss;
^^^^^^^^^
return {};
}
I have utilized the @types/jsonwebtoken
library for defining the types. Any assistance in resolving this issue would be highly appreciated.