2019-08-17 23:03:10 +00:00
|
|
|
import { rawDataToServerObject, Server } from '@/api/server/getServer';
|
|
|
|
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
|
|
|
|
|
2020-04-04 05:39:53 +00:00
|
|
|
export default (query?: string): Promise<PaginatedResult<Server>> => {
|
2019-08-17 23:03:10 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2020-04-04 05:39:53 +00:00
|
|
|
http.get(`/api/client`, { params: { include: [ 'allocation' ], query } })
|
2019-08-17 23:03:10 +00:00
|
|
|
.then(({ data }) => resolve({
|
|
|
|
items: (data.data || []).map((datum: any) => rawDataToServerObject(datum.attributes)),
|
|
|
|
pagination: getPaginationSet(data.meta.pagination),
|
|
|
|
}))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|