(login) save login

This commit is contained in:
2021-03-17 23:25:58 +01:00
parent 6f5ea41824
commit 2faabb6c0e
13 changed files with 255 additions and 29 deletions

View File

@@ -0,0 +1,28 @@
import { Octokit } from '@octokit/rest'
import { useAsyncState } from '@vueuse/core'
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
export const useRepos = () => {
const { username, accessToken } = useGitHubLogin()
const repos = useAsyncState(async () => {
if (!accessToken.value || !username.value) {
return []
}
const octokit = new Octokit({
auth: accessToken.value
})
const repoList = await octokit.request('GET /search/repositories', {
q: `user:${username.value}`,
per_page: 100
})
return repoList.data.items.map((item) => item.name)
}, [])
return {
repos: repos.state,
isReady: repos.isReady
}
}