From 9b989e957914b9c081bd8742e0ea91acfff35e18 Mon Sep 17 00:00:00 2001 From: UKDTOM Date: Sat, 6 Jun 2020 20:09:20 +0200 Subject: [PATCH] POEditor Contrubuter now fetched --- src/background.js | 3 +- src/store/modules/poeditor.js | 55 +++++++++++++++++------------------ 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/background.js b/src/background.js index 444f2d2..84c5beb 100644 --- a/src/background.js +++ b/src/background.js @@ -35,7 +35,8 @@ protocol.registerSchemesAsPrivileged([{scheme: 'app', privileges: { secure: true function createWindow () { // Create the browser window. win = new BrowserWindow({ width: 1024, height: 768, webPreferences: { - nodeIntegration: true + nodeIntegration: true, + webSecurity: false } }) if (process.env.WEBPACK_DEV_SERVER_URL) { diff --git a/src/store/modules/poeditor.js b/src/store/modules/poeditor.js index 38a42d3..963d0d9 100644 --- a/src/store/modules/poeditor.js +++ b/src/store/modules/poeditor.js @@ -11,36 +11,35 @@ const mutations = { }, }; +const qs = require('querystring') const actions = { fetchPOEContrib({ commit }) { - axios({ - method: 'post', - url: 'https://api.poeditor.com/v2/contributors/list', - headers: - { - "Access-Control-Allow-Origin": "*" - }, - body: - { - 'id' : '342617', - 'api-token': "5166c4294ff7fb3a82cbdc82958e850e", - }, - }) - .then((response) => { - - console.log(response) - commit('UPDATE_CONTRIBUTORS', response) - }) - .catch(function (error) { - if (error.response) { - console.log(error.response.data) - alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message) - } else if (error.request) { - console.log(error.request); - } else { - console.log('Error', error.message); - } - }); + const requestBody = { + id: '342617', + api_token: '5166c4294ff7fb3a82cbdc82958e850e' + } + + const config = { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + } + + axios.post('https://api.poeditor.com/v2/contributors/list', qs.stringify(requestBody), config) + .then((response) => { + console.log(response) + commit('UPDATE_CONTRIBUTORS', response) + }) + .catch(function (error) { + if (error.response) { + console.log(error.response.data) + alert(error.response.data.errors[0].code + " " + error.response.data.errors[0].message) + } else if (error.request) { + console.log(error.request); + } else { + console.log('Error', error.message); + } + }); } }