centralized API-URL in quasar.conf.js
This commit is contained in:
parent
8ee93cd9c0
commit
789c04a8e8
@ -100,7 +100,15 @@ module.exports = function (ctx) {
|
|||||||
loader: 'eslint-loader',
|
loader: 'eslint-loader',
|
||||||
exclude: /node_modules/
|
exclude: /node_modules/
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
env: ctx.dev
|
||||||
|
? { // Base URL for API-Calls: DEV
|
||||||
|
API: JSON.stringify('http://localhost:8080')
|
||||||
|
}
|
||||||
|
: { // Base URL for API-Calls: PRODUCTION (build)
|
||||||
|
API: JSON.stringify('http://se.hs-heilbronn.de:8090')
|
||||||
|
//API: JSON.stringify('http://se.hs-heilbronn.de:8090')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
devServer: {
|
devServer: {
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
|
const axiosInstance = axios.create({
|
||||||
|
baseURL: process.env.API
|
||||||
|
});
|
||||||
|
console.log("process.env.DEV: "+process.env.DEV);
|
||||||
|
console.log("process.env.API: "+process.env.API);
|
||||||
|
|
||||||
export default async ({ Vue }) => {
|
export default async ({ Vue }) => {
|
||||||
Vue.prototype.$axios = axios;
|
//Vue.prototype.$axios = axios;
|
||||||
|
Vue.prototype.$axios = axiosInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { axiosInstance }
|
||||||
|
|||||||
@ -113,7 +113,7 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchAllCaches() {
|
fetchAllCaches() {
|
||||||
this.$axios.get('http://localhost:8080/api/allCaches')
|
this.$axios.get('/api/allCaches')
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log("Caches: " + this.caches);
|
console.log("Caches: " + this.caches);
|
||||||
this.caches = response.data;
|
this.caches = response.data;
|
||||||
@ -126,7 +126,7 @@
|
|||||||
},
|
},
|
||||||
deleteCache(id) {
|
deleteCache(id) {
|
||||||
console.log('delete cache: ' + id)
|
console.log('delete cache: ' + id)
|
||||||
this.$axios.delete('http://localhost:8080/api/deleteCache', {params: {cacheID: id}})
|
this.$axios.delete('/api/deleteCache', {params: {cacheID: id}})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.fetchAllCaches()
|
this.fetchAllCaches()
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user