misc_pterodactyl-panel/resources/scripts/api/getServers.ts

25 lines
729 B
TypeScript
Raw Normal View History

import http, { getPaginationSet, PaginatedResult } from '@/api/http';
2022-02-27 16:40:51 +00:00
import { Transformers, Server } from '@definitions/user';
interface QueryParams {
query?: string;
page?: number;
type?: string;
}
export default ({ query, ...params }: QueryParams): Promise<PaginatedResult<Server>> => {
return new Promise((resolve, reject) => {
2020-07-05 01:30:50 +00:00
http.get('/api/client', {
params: {
'filter[*]': query,
...params,
},
})
.then(({ data }) => resolve({
2022-02-27 16:40:51 +00:00
items: (data.data || []).map(Transformers.toServer),
pagination: getPaginationSet(data.meta.pagination),
}))
.catch(reject);
});
};