Skip to content

Commit

Permalink
Clean up refreshJwt
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthachatterjee committed Jun 8, 2022
1 parent 07d4ca2 commit c840949
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions packages/wrangler/src/pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1138,17 +1138,15 @@ const createDeployment: CommandModule<

const files = [...fileMap.values()];

let jwt = "";

async function refreshJwt() {
jwt = (
async function fetchJwt(): Promise<string> {
return (
await fetchResult<{ jwt: string }>(
`/accounts/${accountId}/pages/projects/${projectName}/upload-token`
)
).jwt;
}

await refreshJwt();
let jwt = await fetchJwt();

const start = Date.now();

Expand Down Expand Up @@ -1247,7 +1245,7 @@ const createDeployment: CommandModule<

if ((e as { code: number }).code === 8000013) {
// Looks like the JWT expired, fetch another one
await refreshJwt();
jwt = await fetchJwt();
}
return doUpload();
} else {
Expand Down

0 comments on commit c840949

Please sign in to comment.