diff --git a/src/components/OutputPan.vue b/src/components/OutputPan.vue index d070996..0614b7d 100644 --- a/src/components/OutputPan.vue +++ b/src/components/OutputPan.vue @@ -261,10 +261,9 @@ export default { activePan: this.activePan } ) - const params = {} + const headers = {} if (token) { - // eslint-disable-next-line camelcase - params.access_token = token + headers['Authorization'] = 'token ' + token } const shouldUpdateGist = this.canUpdateGist && !saveNew const url = `https://api.github.com/gists${ @@ -274,7 +273,7 @@ export default { }` const method = shouldUpdateGist ? 'PATCH' : 'POST' const { data } = await axios(url, { - params, + headers, method, data: { public: false, @@ -290,7 +289,7 @@ export default { // Update gist id in the description of newly created gist axios(`https://api.github.com/gists/${data.id}`, { method: 'PATCH', - params, + headers, data: { description: `Try it online! https://codepan.net/gist/${ data.id diff --git a/src/utils/github-api.js b/src/utils/github-api.js index 26d8ef3..b69058c 100644 --- a/src/utils/github-api.js +++ b/src/utils/github-api.js @@ -1,15 +1,13 @@ import axios from 'axios' import notie from 'notie' -export default async function (endpoint, token, errCb = () => {}) { - const params = { - // eslint-disable-next-line camelcase - access_token: token - } +export default async function (endpoint, token, errCb = () => { }) { + + const headers = { 'Authorization': 'token ' + token }; try { const data = await axios.get(`https://api.github.com/${endpoint}`, { - params + headers }).then(res => res.data) return data