Skip to content

Commit

Permalink
#442292 - Adapt functionality when dataset is not an array
Browse files Browse the repository at this point in the history
  • Loading branch information
ppel-gmv committed Sep 5, 2024
1 parent 1adb9de commit ee8e48c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/api/get-federated-catalog/controllers/get-federated-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
delete body.sortOrder
delete body.sortField

const countResponse = await axios.post(countCatalogUrl, body,{
const countResponse = await axios.post(countCatalogUrl, body, {
headers: {
Authorization: `Bearer ${accessToken}`
}
Expand All @@ -40,14 +40,21 @@ module.exports = {
});

catalogsResponse.data.forEach(catalog => {
delete catalog['http://www.w3.org/ns/dcat#service'];
delete catalog['originator'];
delete catalog['http://www.w3.org/ns/dcat#service'];
delete catalog['originator'];

catalog['http://www.w3.org/ns/dcat#dataset'].forEach(dataset => {
delete dataset['http://www.w3.org/ns/dcat#distribution'];
delete dataset['odrl:hasPolicy'];
delete dataset['@type'];
const datasets = catalog['http://www.w3.org/ns/dcat#dataset'];
if (Array.isArray(datasets)) {
datasets.forEach(dataset => {
delete dataset['http://www.w3.org/ns/dcat#distribution'];
delete dataset['odrl:hasPolicy'];
delete dataset['@type'];
});
} else {
delete datasets['http://www.w3.org/ns/dcat#distribution'];
delete datasets['odrl:hasPolicy'];
delete datasets['@type'];
}
});

const finalResponse = {
Expand Down

0 comments on commit ee8e48c

Please sign in to comment.