UNPKG

@vlsergey/react-bootstrap-pagetable

Version:

Complex solution to work with pageable data, including sorting, filtering, actions, changing displayed columns, etc.

21 lines (20 loc) 828 B
export default function springDataRestResponseToPage(key, response) { var _embedded = response._embedded; if (!_embedded) { throw new Error('Missing property \'_embedded\' in response object'); } var content = _embedded[key]; if (content === null || content === undefined) { throw new Error("Missing property '" + key + "' in response '_embedded' object property"); } if (!Array.isArray(content)) { throw new Error("Property '" + key + "' in response '_embedded' object property is not an array"); } var _a = response.page, number = _a.number, totalElements = _a.totalElements, totalPages = _a.totalPages; return { content: content, number: number, totalElements: totalElements, totalPages: totalPages, }; }