From f399df1285693538b213daea1be01271666cab8d Mon Sep 17 00:00:00 2001 From: RemixDev Date: Wed, 12 Jan 2022 22:13:52 +0100 Subject: [PATCH] Changed POST calls to actual POST calls --- src/app.js | 4 ++-- src/components/pages/Settings.vue | 7 +++---- src/utils/api.js | 2 +- src/utils/downloads.js | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app.js b/src/app.js index d8f60b1..ac125d8 100644 --- a/src/app.js +++ b/src/app.js @@ -66,9 +66,9 @@ async function startApp() { let result if (accountNum !== 0) { - result = await fetchData('login-arl', { arl, force: true, child: accountNum || 0 }, 'POST') + result = await postToServer('loginArl', { arl, force: true, child: accountNum || 0 }) } else { - result = await fetchData('login-arl', { arl }, 'POST') + result = await postToServer('loginArl', { arl }) } return result diff --git a/src/components/pages/Settings.vue b/src/components/pages/Settings.vue index 56e513e..c84924b 100644 --- a/src/components/pages/Settings.vue +++ b/src/components/pages/Settings.vue @@ -982,7 +982,7 @@ export default { }, async login(arl, force = false) { toast(this.$t('toasts.loggingIn'), 'loading', false, 'login-toast') - const data = await fetchData('login-arl', { arl, force, child: this.accountNum }, 'POST') + const data = await postToServer('loginArl', { arl, force, child: this.accountNum }) const { status, user, childs, currentChild } = data this.accounts = childs this.accountNum = currentChild @@ -1024,7 +1024,7 @@ export default { toast(this.$t('toasts.loggingIn'), 'loading', false, 'login-toast') - const { accessToken, arl } = await postToServer('loginWithCredentials', { + const { accessToken, arl } = await postToServer('loginEmail', { email, password, accessToken: this.accessToken @@ -1038,8 +1038,7 @@ export default { window.api.send('applogin') }, async changeAccount() { - // socket.emit('changeAccount', this.accountNum) - const [user, accountNum] = await fetchData('changeAccount', { child: this.accountNum }) + const [user, accountNum] = await fetchData('changeAccount', { child: this.accountNum }, 'POST') this.accountChanged(user, accountNum) }, diff --git a/src/utils/api.js b/src/utils/api.js index c8be5f7..66bc08e 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -25,7 +25,7 @@ export function sendToServer(key, data) { }) } -export const postToServer = (endpoint, data) => { +export function postToServer(endpoint, data) { const url = new URL(`${window.location.origin}/api/${endpoint}`) return fetch(url, { diff --git a/src/utils/downloads.js b/src/utils/downloads.js index 1bf6e91..129a575 100644 --- a/src/utils/downloads.js +++ b/src/utils/downloads.js @@ -1,4 +1,4 @@ -import { fetchData } from '@/utils/api' +import { postToServer } from '@/utils/api' /** * @param {string} url @@ -7,7 +7,7 @@ import { fetchData } from '@/utils/api' export function sendAddToQueue(url, bitrate = null) { if (!url) throw new Error('No URL given to sendAddToQueue function!') - fetchData('addToQueue', { url, bitrate }, 'POST') + postToServer('addToQueue', { url, bitrate }) } /**