primevue-mirror/service/CustomerService.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-07-02 15:17:07 +00:00
export default class CustomerService {
constructor() {
const runtimeConfig = useRuntimeConfig();
2022-12-28 08:48:05 +00:00
this.contextPath = runtimeConfig.public.contextPath;
}
2021-10-05 07:41:07 +00:00
getCustomersSmall() {
return fetch(this.contextPath + 'demo/data/customers-small.json')
2022-09-14 14:26:41 +00:00
.then((res) => res.json())
.then((d) => d.data);
2021-10-05 07:41:07 +00:00
}
getCustomersMedium() {
return fetch(this.contextPath + 'demo/data/customers-medium.json')
2022-09-14 14:26:41 +00:00
.then((res) => res.json())
.then((d) => d.data);
2021-10-05 07:41:07 +00:00
}
2020-03-04 12:10:34 +00:00
2021-10-05 07:41:07 +00:00
getCustomersLarge() {
return fetch(this.contextPath + 'demo/data/customers-large.json')
2022-09-14 14:26:41 +00:00
.then((res) => res.json())
.then((d) => d.data);
2021-10-05 07:41:07 +00:00
}
2020-03-04 12:10:34 +00:00
2021-10-05 07:41:07 +00:00
getCustomersXLarge() {
return fetch(this.contextPath + 'demo/data/customers-xlarge.json')
2022-09-14 14:26:41 +00:00
.then((res) => res.json())
.then((d) => d.data);
2021-10-05 07:41:07 +00:00
}
2020-03-04 12:10:34 +00:00
2021-10-05 07:41:07 +00:00
getCustomers(params) {
2022-09-14 14:26:41 +00:00
const queryParams = params
? Object.keys(params)
.map((k) => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))
.join('&')
: '';
2022-12-20 12:32:32 +00:00
2022-09-14 14:26:41 +00:00
return fetch('https://www.primefaces.org/data/customers?' + queryParams).then((res) => res.json());
2021-10-05 07:41:07 +00:00
}
}