diff --git a/src/plugins/api.js b/src/plugins/api.js index 7469455..ebfbbe6 100644 --- a/src/plugins/api.js +++ b/src/plugins/api.js @@ -50,7 +50,6 @@ export async function getUserName() { * @returns {Promise} informations about the branch with attributes 'commit: { sha }', etc. */ export async function getCommitSha() { - const headers = getHeaders() return axios.get(`${BASE_URL_REPO}/${repoOwner}/${repoName}/branches/${branch}`) .then((response) => response.data) .catch((err) => { @@ -66,9 +65,6 @@ export async function getCommitSha() { * @returns {Promise} informations about the newly created file with attributes 'sha', etc. */ export async function createBlobs(file) { - const headers = getHeaders(); - const copyHeader = { ...headers }; // Spread syntax to create a shallow copy - copyHeader["Accept"] = "application/vnd.github+json"; return axios.post(`${BASE_URL_REPO}/${repoOwner}/${repoName}/git/blobs`, ({ content: file, diff --git a/src/plugins/apiConfig/config.js b/src/plugins/apiConfig/config.js index e5514a5..8e6e6c5 100644 --- a/src/plugins/apiConfig/config.js +++ b/src/plugins/apiConfig/config.js @@ -1,12 +1,7 @@ import axios from "axios" const BASE_URL_USER = "https://api.github.com/user" const BASE_URL_REPO = "https://api.github.com/repos" -const getHeaders = () => { - return { - Authorization: `Bearer ${localStorage?.getItem("authId")}` - } -} const setHeaders = () => { - axios.defaults.headers.common['Authorization'] = getHeaders().Authorization; + axios.defaults.headers.common['Authorization'] = `Bearer ${localStorage?.getItem("authId")}` } export { BASE_URL_REPO, BASE_URL_USER, setHeaders }