Skip to content

Commit

Permalink
fixed headers error
Browse files Browse the repository at this point in the history
  • Loading branch information
Moneexa committed Dec 2, 2023
1 parent 1c019e9 commit f655d27
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions src/plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export async function getUserName() {
* @returns {Promise<object[]>} 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) => {
Expand All @@ -66,9 +65,6 @@ export async function getCommitSha() {
* @returns {Promise<object[]>} 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,
Expand Down
7 changes: 1 addition & 6 deletions src/plugins/apiConfig/config.js
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit f655d27

Please sign in to comment.