From 0644237c3848067989892371aed33a0f69c4d8ab Mon Sep 17 00:00:00 2001 From: karannakra Date: Thu, 18 May 2023 02:32:44 +0530 Subject: [PATCH] replace var with const --- src/components/jwt.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/jwt.ts b/src/components/jwt.ts index 1ed39f02..56279eb9 100644 --- a/src/components/jwt.ts +++ b/src/components/jwt.ts @@ -1,10 +1,11 @@ export function parseJwt(token: string) { - var base64Url = token.split('.')[1]; + const base64Url = token.split('.')[1]; if (!base64Url) { return; } - var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); - var jsonPayload = decodeURIComponent( + + const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); + const jsonPayload = decodeURIComponent( window .atob(base64) .split('') @@ -18,6 +19,7 @@ export function parseJwt(token: string) { if (typeof parsed === 'object' && parsed !== null) { return parsed as Record; } + console.error('Could not parse JWT payload', parsed); return; } catch (e) {