@@ -19,12 +19,13 @@ export async function getGitTree(SHA: string, recursive = false) {
19
19
const authStore = useAuthStore ( ) ;
20
20
21
21
try {
22
- const response = await axios . get < TreeResponse > ( url . toString ( ) , {
23
- headers : {
24
- Accept : "application/vnd.github+json" ,
25
- Authorization : `Bearer ${ authStore . access_token } ` ,
26
- } ,
27
- } ) ;
22
+ const headers : { [ index : string ] : string } = {
23
+ Accept : "application/vnd.github+json" ,
24
+ } ;
25
+ if ( authStore . access_token )
26
+ headers . Authorization = `Bearer ${ authStore . access_token } ` ;
27
+
28
+ const response = await axios . get < TreeResponse > ( url . toString ( ) , headers ) ;
28
29
console . log ( response ) ;
29
30
return response . data ;
30
31
} catch ( e : any ) {
@@ -50,13 +51,13 @@ export async function getCommit(path: string) {
50
51
const authStore = useAuthStore ( ) ;
51
52
52
53
try {
53
- console . log ( endpoint . toString ( ) ) ;
54
- const response = await axios . get < CommitList > ( endpoint . toString ( ) , {
55
- headers : {
56
- Accept : "application/vnd.github+json" ,
57
- Authorization : `Bearer ${ authStore . access_token } ` ,
58
- } ,
59
- } ) ;
54
+ const headers : { [ index : string ] : string } = {
55
+ Accept : "application/vnd.github+json" ,
56
+ } ;
57
+ if ( authStore . access_token )
58
+ headers . Authorization = `Bearer ${ authStore . access_token } ` ;
59
+
60
+ const response = await axios . get < CommitList > ( endpoint . toString ( ) , headers ) ;
60
61
console . log ( response ) ;
61
62
console . log ( `Retrieved commit ${ response . data [ 0 ] . sha } ` ) ;
62
63
return response . data [ 0 ] ;
0 commit comments