Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit6d5661a

Browse files
committed
fix(github-api): add default header option for fetch repo info
1 parente5ce85b commit6d5661a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

‎services/github_api/client.js‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ const jsonOptions = {
2424
// graphql client
2525
exportconstgraphqlClient=makeGithubExplore(graphqlEndpoint,token)
2626

27-
exportconstrestClient=(api,fmt='json')=>{
28-
if(fmt==='json'){
29-
returnfetch(`${api}`,jsonOptions).then(r=>r.json())
27+
exportconstrestClient=(api,fmt='default')=>{
28+
switch(fmt){
29+
case'json':{
30+
returnfetch(`${api}`,jsonOptions).then(r=>r.json())
31+
}
32+
case'raw':{
33+
returnfetch(`${api}`,rawOptions).then(r=>r.text())
34+
}
35+
default:{
36+
returnfetch(`${api}`).then(r=>r.text())
37+
}
3038
}
31-
32-
returnfetch(`${api}`,rawOptions).then(r=>r.text())
3339
}

‎services/github_api/repo_search.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ const contributorsQuery = (owner, name) => {
1414
constpath='contributors?page=1&per_page=8'
1515
constapi=`${restEndpoint}/repos/${owner}/${name}/${path}`
1616

17-
returnrestClient(`${api}`)
17+
returnrestClient(`${api}`,'json')
1818
}
1919

2020
constreadmeQuery=(owner,name)=>{
2121
returnrestClient(`${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+
*/
2432
exportconstsearchRepoPromise=(owner,name)=>
2533
Promise.all([
2634
timeout(baseInfoQuery(owner,name),TIMEOUT_SEC),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp