Files
WGDashboard/src/static/client/src/utilities/request.js
T
daanselen 1e495c546c Revert "Merge branch 'v4.3.3-dev' into main"
This reverts commit 3586ddce4d, reversing
changes made to 27ec65a970.
2026-03-31 23:15:34 +02:00

36 lines
855 B
JavaScript

import axios from "axios";
import {useRouter} from "vue-router";
export const requestURl = (url) => {
return import.meta.env.MODE === 'development' ? '/client' + url
: `${window.location.protocol}//${(window.location.host + window.location.pathname + url).replace(/\/\//g, '/')}`
}
// const router = useRouter()
export const axiosPost = async (URL, body = {}) => {
try{
const res = await axios.post(requestURl(URL), body)
return res.data
} catch (error){
console.log(error)
// if (error.status === 401){
// await router.push('/signin')
// }
return undefined
}
}
export const axiosGet = async (URL, query = {}) => {
try{
const res = await axios.get(requestURl(URL), query)
return res.data
} catch (error){
console.log(error)
// if (error.status === 401){
// await router.push('/signin')
// }
return undefined
}
}