Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/components/OutputPan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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${
Expand All @@ -274,7 +273,7 @@ export default {
}`
const method = shouldUpdateGist ? 'PATCH' : 'POST'
const { data } = await axios(url, {
params,
headers,
method,
data: {
public: false,
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions src/utils/github-api.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down