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 = {
24
24
// graphql client
25
25
export const graphqlClient = makeGithubExplore ( graphqlEndpoint , token )
26
26
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
+ }
30
38
}
31
-
32
- return fetch ( `${ api } ` , rawOptions ) . then ( r => r . text ( ) )
33
39
}
Original file line number Diff line number Diff line change @@ -14,13 +14,21 @@ const contributorsQuery = (owner, name) => {
14
14
const path = 'contributors?page=1&per_page=8'
15
15
const api = `${ restEndpoint } /repos/${ owner } /${ name } /${ path } `
16
16
17
- return restClient ( `${ api } ` )
17
+ return restClient ( `${ api } ` , 'json' )
18
18
}
19
19
20
20
const readmeQuery = ( owner , name ) => {
21
21
return restClient ( `${ restEndpoint } /repos/${ owner } /${ name } /readme` , 'raw' )
22
22
}
23
23
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
+ */
24
32
export const searchRepoPromise = ( owner , name ) =>
25
33
Promise . all ( [
26
34
timeout ( baseInfoQuery ( owner , name ) , TIMEOUT_SEC ) ,
You can’t perform that action at this time.
0 commit comments