22 * Learning data fetching utilities for DaleStudy GitHub App
33 */
44
5+ import { getGitHubHeaders } from "./github.js" ;
6+
57/**
68 * Fetches problem-categories.json from the repo root via GitHub API.
79 * Returns parsed JSON object, or null if the file is not found (404).
@@ -17,9 +19,8 @@ export async function fetchProblemCategories(repoOwner, repoName, appToken) {
1719
1820 const response = await fetch ( url , {
1921 headers : {
20- Authorization : `Bearer ${ appToken } ` ,
22+ ... getGitHubHeaders ( appToken ) ,
2123 Accept : "application/vnd.github.raw+json" ,
22- "User-Agent" : "DaleStudy-GitHub-App" ,
2324 } ,
2425 } ) ;
2526
@@ -57,11 +58,7 @@ export async function fetchUserSolutions(
5758 const url = `https://api.github.com/repos/${ repoOwner } /${ repoName } /git/trees/main?recursive=1` ;
5859
5960 const response = await fetch ( url , {
60- headers : {
61- Authorization : `Bearer ${ appToken } ` ,
62- Accept : "application/vnd.github+json" ,
63- "User-Agent" : "DaleStudy-GitHub-App" ,
64- } ,
61+ headers : getGitHubHeaders ( appToken ) ,
6562 } ) ;
6663
6764 if ( ! response . ok ) {
@@ -113,11 +110,7 @@ export async function fetchPRSubmissions(
113110 const url = `https://api.github.com/repos/${ repoOwner } /${ repoName } /pulls/${ prNumber } /files?per_page=100` ;
114111
115112 const response = await fetch ( url , {
116- headers : {
117- Authorization : `Bearer ${ appToken } ` ,
118- Accept : "application/vnd.github+json" ,
119- "User-Agent" : "DaleStudy-GitHub-App" ,
120- } ,
113+ headers : getGitHubHeaders ( appToken ) ,
121114 } ) ;
122115
123116 if ( ! response . ok ) {
0 commit comments