Skip to content

Commit 72d0c71

Browse files
committed
use anon token to fetch gists
1 parent 16d9ed5 commit 72d0c71

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

scripts/fetch-data/fetch/gists.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ export async function fetchGists() {
1111

1212
try {
1313
const gistsUrl = `https://api.github.com/users/${username}/gists?per_page=${state.perPage}`;
14-
const dataStr = await downloadTextFile(gistsUrl, null);
14+
const dataStr = await downloadTextFile(gistsUrl, null, { token: '' });
1515
const data: Gist[] = JSON.parse(dataStr);
1616

1717
for (const gist of data) {
1818
for (const file of Object.values(gist.files)) {
1919
if (file.raw_url) {
2020
try {
21-
const content = await downloadTextFile(file.raw_url, null);
21+
const content = await downloadTextFile(file.raw_url, null, {
22+
token: '',
23+
});
2224
file.content = content;
2325
} catch (e) {
2426
err(`Error fetching content for ${file.filename}`, e);

scripts/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function downloadFile(
1717
const { accept, isBinary = false } = options;
1818
let { token } = options;
1919
const headers: Record<string, string> = {};
20-
if (!token) token = process.env.GITHUB_TOKEN;
20+
if (token === undefined) token = process.env.GITHUB_TOKEN;
2121
if (token) {
2222
headers.Authorization = `token ${token}`;
2323
}

0 commit comments

Comments
 (0)