Skip to content

Commit 7d2004f

Browse files
jakub.vilhanjakub.vilhan
jakub.vilhan
authored and
jakub.vilhan
committed
Fix duplicate code
1 parent 8a2b309 commit 7d2004f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/callback-endpoint.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ export const createCallbackEndpoint = (
4646

4747
if (pluginOptions.getToken) {
4848
access_token = pluginOptions.getToken(code);
49-
50-
if (typeof access_token !== "string")
51-
throw new Error(`No access token: ${access_token}`);
5249
} else {
5350
const tokenResponse = await fetch(pluginOptions.tokenEndpoint, {
5451
method: "POST",
@@ -67,11 +64,11 @@ export const createCallbackEndpoint = (
6764
const tokenData = await tokenResponse.json();
6865

6966
access_token = tokenData?.access_token;
70-
71-
if (typeof access_token !== "string")
72-
throw new Error(`No access token: ${JSON.stringify(tokenData)}`);
7367
}
7468

69+
if (typeof access_token !== "string")
70+
throw new Error(`No access token: ${access_token}`);
71+
7572
// /////////////////////////////////////
7673
// get user info
7774
// /////////////////////////////////////

0 commit comments

Comments
 (0)