Skip to content

Commit

Permalink
Merge branch 'feature/434762_paginated_catalog' into 'develop'
Browse files Browse the repository at this point in the history
#434762 - Changed catalog request for pagination

See merge request upm-inesdata/inesdata-public-portal-backend!4
  • Loading branch information
ralconada-gmv committed Jun 20, 2024
2 parents a790461 + d7ee254 commit 8cb41a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/api/get-federated-catalog/controllers/get-federated-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,31 @@ module.exports = {
}

// URL for fetching the federated catalog
const catalogUrl = `${process.env.CATALOG_BASE_URL}/management/federatedcatalog`;
const countCatalogUrl = `${process.env.CATALOG_BASE_URL}/management/pagination/count?type=federatedCatalog`;

const countResponse = await axios.get(countCatalogUrl, {
headers: {
Authorization: `Bearer ${accessToken}`
}
});

// URL for fetching the federated catalog
const catalogUrl = `${process.env.CATALOG_BASE_URL}/management/federatedcatalog/request`;

// Fetch the federated catalog using the access token
const response = await axios.post(catalogUrl, {}, {
const catalogsResponse = await axios.post(catalogUrl, ctx.request.body, {
headers: {
Authorization: `Bearer ${accessToken}`
}
});

const finalResponse = {
catalogs: catalogsResponse.data,
totalElements: countResponse.data
};

// Respond with the fetched data
ctx.body = response.data;
ctx.body = finalResponse;
} catch (err) {
console.error('Error:', err);
ctx.body = { message: 'Error fetching federated catalog!', details: err.message };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
"routes": [
{
"method": "GET",
"method": "POST",
"path": "/get-federated-catalog",
"handler": "get-federated-catalog.getFederatedCatalog"
}
Expand Down

0 comments on commit 8cb41a0

Please sign in to comment.