@@ -77,21 +77,7 @@ export async function fetchGitHubSponsors(
7777 const tiers = config . tiers ?. filter ( tier => tier . monthlyDollars && tier . monthlyDollars > 0 ) . sort ( ( a , b ) => b . monthlyDollars ! - a . monthlyDollars ! )
7878 do {
7979 const query = makeQuery ( login , type , ! config . includePastSponsors , cursor )
80- const data = await $fetch ( API , {
81- method : 'POST' ,
82- body : { query } ,
83- headers : {
84- 'Authorization' : `bearer ${ token } ` ,
85- 'Content-Type' : 'application/json' ,
86- } ,
87- } ) as any
88-
89- if ( ! data )
90- throw new Error ( `Get no response on requesting ${ API } ` )
91- else if ( data . errors ?. [ 0 ] ?. type === 'INSUFFICIENT_SCOPES' )
92- throw new Error ( 'Token is missing the `read:user` and/or `read:org` scopes' )
93- else if ( data . errors ?. length )
94- throw new Error ( `GitHub API error:\n${ JSON . stringify ( data . errors , null , 2 ) } ` )
80+ const data = await requestGitHubGraphQL ( token , query )
9581
9682 sponsors . push (
9783 ...( data . data [ type ] . sponsorshipsAsMaintainer . nodes || [ ] ) ,
@@ -224,7 +210,7 @@ function assertGitHubSponsoringParams(
224210 throw new Error ( 'GitHub type must be either `user` or `organization`' )
225211}
226212
227- async function requestGitHubSponsoringGraphQL ( token : string , query : string ) : Promise < any > {
213+ async function requestGitHubGraphQL ( token : string , query : string ) : Promise < any > {
228214 const data = await $fetch ( API , {
229215 method : 'POST' ,
230216 body : { query } ,
@@ -255,7 +241,7 @@ async function fetchGitHubSponsoringNodes(
255241
256242 do {
257243 const query = makeSponsoringQuery ( login , type , activeOnly , cursor )
258- const data = await requestGitHubSponsoringGraphQL ( token , query )
244+ const data = await requestGitHubGraphQL ( token , query )
259245 const page = data . data ?. [ type ] ?. sponsorshipsAsSponsor
260246 if ( ! page )
261247 throw new Error ( 'Invalid GitHub response: `sponsorshipsAsSponsor` is missing' )
@@ -419,7 +405,7 @@ export async function fetchGitHubTotalSponsorshipAmountAsSponsor(
419405 assertGitHubSponsoringParams ( token , login , type )
420406
421407 const query = makeSponsoringTotalAmountQuery ( login , type , options )
422- const data = await requestGitHubSponsoringGraphQL ( token , query )
408+ const data = await requestGitHubGraphQL ( token , query )
423409
424410 const totalInCents = data . data ?. [ type ] ?. totalSponsorshipAmountAsSponsorInCents
425411 if ( typeof totalInCents !== 'number' )
0 commit comments