Skip to content

Simplify the download data from github apis #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,13 @@ export async function fetchDataFile(params: FileParamsWithSHA) {
// ).auth(`token ${cachedPat}`)
// :

let res;
const text = await wretch(
`https://raw.githubusercontent.com/${owner}/${name}/${sha}/${filename}`
)
const res = await githubWretch
.url(`/repos/${owner}/${name}/contents/${filename}?ref=${sha}`)
.get()
.notFound(async () => {
if (cachedPat) {
const data = await githubWretch
.url(`/repos/${owner}/${name}/contents/${filename}`)
.get()
.json();
const content = atob(data.content);
return content;
} else {
throw new Error("Data file not found");
}
})
.text();
.json();

const text =await wretch(res.download_url).get().text()


let data: any;
try {
Expand Down