✨ (github) fetch file with authorization token
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
import { ref } from 'vue'
|
||||
import { request } from '@octokit/request'
|
||||
import { useMarkdown } from '@/hooks/useMarkdown.hook'
|
||||
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
|
||||
import { Octokit } from '@octokit/rest'
|
||||
|
||||
export const useFile = (owner: string, repo: string, sha: string) => {
|
||||
const { accessToken } = useGitHubLogin()
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: accessToken.value
|
||||
})
|
||||
|
||||
const content = ref('')
|
||||
|
||||
const getContent = async () => {
|
||||
const { render } = useMarkdown()
|
||||
const file = await request(
|
||||
const file = await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/git/blobs/{file_sha}',
|
||||
{
|
||||
owner,
|
||||
|
||||
Reference in New Issue
Block a user