Advertisement
kopyl

non-async repo fetching digger

Sep 14th, 2022 (edited)
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fetchRepos = () => {
  2.   apiGithubappReposList()
  3.     .then((GHrepos) => {
  4.       const apiGHRepos =
  5.         // @ts-ignore The endpoint to get the Github repos is wrongly typed
  6.         GHrepos.results?.map((repo: any) => {
  7.           return {
  8.             repo: `${repo}`,
  9.             type: "github",
  10.           };
  11.         }) ?? [];
  12.       setRepos([...apiGHRepos]);
  13.       return apiGHRepos;
  14.     })
  15.     .then((apiGHRepos) => {
  16.       apiGitlabappReposList().then((GLrepos) => {
  17.         const apiGLRepos =
  18.           // @ts-ignore The endpoint to get the Gitlab repos is wrongly typed
  19.           GLrepos.results?.map((repo: any) => {
  20.             return {
  21.               repo: `${repo}`,
  22.               type: "gitlab",
  23.             };
  24.           }) ?? [];
  25.  
  26.         setRepos([...apiGHRepos, ...apiGLRepos]);
  27.       });
  28.     })
  29.     .then(() => {
  30.       setReposFirstLoading(false);
  31.     });
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement