From c9afdd9372f629848a805a0ef456f193613ea18a Mon Sep 17 00:00:00 2001 From: alexeyandreevsky Date: Thu, 14 Mar 2024 21:07:52 +0700 Subject: [PATCH] Convert loader function to fetch api in Blocks.js --- packages/frontend/src/app/blocks/Blocks.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/frontend/src/app/blocks/Blocks.js b/packages/frontend/src/app/blocks/Blocks.js index 05e841590..1fdc7b27d 100644 --- a/packages/frontend/src/app/blocks/Blocks.js +++ b/packages/frontend/src/app/blocks/Blocks.js @@ -23,13 +23,6 @@ const paginateConfig = { } -export async function loader() { - const paginatedBlocks = await Api.getBlocks(paginateConfig.defaultPage, paginateConfig.pageSize.default, 'desc') - const {resultSet, pagination} = paginatedBlocks - - return {blocks: resultSet, total: pagination.total}; -} - function Blocks() { const [loading, setLoading] = useState(true) const [blocks, setBlocks] = useState([]) @@ -42,11 +35,15 @@ function Blocks() { const fetchData = () => { setLoading(true) - - loader().then((res) => { - setBlocks(res.blocks) - setTotal(res.total) + Api.getBlocks( + paginateConfig.defaultPage, + paginateConfig.pageSize.default, + 'desc' + ).then((res) => { + + setBlocks(res.resultSet) + setTotal(res.pagination.total) }).catch((error)=>{