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