Skip to content

Commit

Permalink
fix: surface file fetch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjhicks committed Oct 21, 2024
1 parent 804f50c commit 6ae791a
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions tools/diff-generator/src/lib/file-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,24 @@ async function fetchTokens(tokenName, version, location) {
version !== "latest"
? source + version.replace("@", "%40")
: source + location;
return (
await fetch(`${link}/packages/tokens/${tokenName}`, {
headers: {
Authorization: "Bearer " + githubAPIKey, // api is rate limited without a personal access token
},
})
)
.json()
.then((tokens) => {
return tokens;
})
.catch((e) => {
console.log(e);
});

const url = `${link}/packages/tokens/${tokenName}`;
const result = await fetch(url, {
headers: {
Authorization: "Bearer " + githubAPIKey, // api is rate limited without a personal access token
},
});

if (result && result.status === 200) {
return result
.json()
.then((tokens) => {
return tokens;
})
.catch((error) => {
console.log(error);
});
} else {
throw new Error(url + "\n\t" + result.status + ": " + result.statusText);
}
}

0 comments on commit 6ae791a

Please sign in to comment.