This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -24,10 +24,16 @@ const jsonOptions = {
2424// graphql client
2525export const graphqlClient = makeGithubExplore ( graphqlEndpoint , token )
2626
27- export const restClient = ( api , fmt = 'json' ) => {
28- if ( fmt === 'json' ) {
29- return fetch ( `${ api } ` , jsonOptions ) . then ( r => r . json ( ) )
27+ export const restClient = ( api , fmt = 'default' ) => {
28+ switch ( fmt ) {
29+ case 'json' : {
30+ return fetch ( `${ api } ` , jsonOptions ) . then ( r => r . json ( ) )
31+ }
32+ case 'raw' : {
33+ return fetch ( `${ api } ` , rawOptions ) . then ( r => r . text ( ) )
34+ }
35+ default : {
36+ return fetch ( `${ api } ` ) . then ( r => r . text ( ) )
37+ }
3038 }
31-
32- return fetch ( `${ api } ` , rawOptions ) . then ( r => r . text ( ) )
3339}
Original file line number Diff line number Diff line change @@ -14,13 +14,21 @@ const contributorsQuery = (owner, name) => {
1414 const path = 'contributors?page=1&per_page=8'
1515 const api = `${ restEndpoint } /repos/${ owner } /${ name } /${ path } `
1616
17- return restClient ( `${ api } ` )
17+ return restClient ( `${ api } ` , 'json' )
1818}
1919
2020const readmeQuery = ( owner , name ) => {
2121 return restClient ( `${ restEndpoint } /repos/${ owner } /${ name } /readme` , 'raw' )
2222}
2323
24+ /**
25+ * @param {string } owner: repo owner
26+ * @param {string } name: repo name
27+ *
28+ * NOTE: use readmeQuery for readme instead of graphql is readme
29+ * has a lots of ext, like readme.md | readme.markdown ...
30+ *
31+ */
2432export const searchRepoPromise = ( owner , name ) =>
2533 Promise . all ( [
2634 timeout ( baseInfoQuery ( owner , name ) , TIMEOUT_SEC ) ,
You can’t perform that action at this time.
0 commit comments