Removed code duplication and get baseURL from nuxt runtime

This commit is contained in:
Cagatay Civici 2022-12-27 23:54:26 +03:00
parent 0c840beded
commit 06df25c7cc
34 changed files with 215 additions and 244 deletions

View file

@ -1,14 +1,17 @@
const baseUrl = process.env.NODE_ENV === 'production' ? '/primevue-nuxt/' : '/';
export default class NodeService {
constructor() {
const runtimeConfig = useRuntimeConfig();
this.contextPath = runtimeConfig.public.contextPath;
}
getTreeTableNodes() {
return fetch(baseUrl + 'demo/data/treetablenodes.json')
return fetch(this.contextPath + 'demo/data/treetablenodes.json')
.then((res) => res.json())
.then((d) => d.root);
}
getTreeNodes() {
return fetch(baseUrl + 'demo/data/treenodes.json')
return fetch(this.contextPath + 'demo/data/treenodes.json')
.then((res) => res.json())
.then((d) => d.root);
}