Changed POST calls to actual POST calls

This commit is contained in:
RemixDev 2022-01-12 22:13:52 +01:00
parent aef5c775ba
commit f399df1285
4 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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)
},

View File

@ -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, {

View File

@ -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 })
}
/**