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,8 +1,8 @@
const baseUrl = process.env.NODE_ENV === 'production' ? '/primevue-nuxt/' : '/';
export default class CountryService {
getCountries() {
return fetch(baseUrl + 'demo/data/countries.json')
const runtimeConfig = useRuntimeConfig();
return fetch(runtimeConfig.public.contextPath + 'demo/data/countries.json')
.then((res) => res.json())
.then((d) => d.data);
}