I'm trying to compile a typescript file and it keeps throwing this error from the compiler:
error TS2339: Property 'payload' does not exist on type 'string | object'.
Property 'payload' does not exist on type 'string'.
Code in question:
decode(token: string): any {
const decodedJWT = jwt.decode(token, { complete: true });
const issuer = decodedJWT.payload.iss;
^^^^^^^^^
return {};
}
I'm using the @types/jsonwebtoken
library to define the types. Any help would be much appreciated.