Skip to content

Commit

Permalink
#434762 - Added number of total elements in the response
Browse files Browse the repository at this point in the history
  • Loading branch information
ppel-gmv committed Jun 19, 2024
1 parent ed3a0b0 commit d7ee254
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/api/get-federated-catalog/controllers/get-federated-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,32 @@ module.exports = {
return;
}

// URL for fetching the federated catalog
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, ctx.request.body, {
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

0 comments on commit d7ee254

Please sign in to comment.