From dbfb28640709071a39fe9b9d35f29d23c8b6b9a3 Mon Sep 17 00:00:00 2001 From: Karel Hala Date: Wed, 20 Nov 2019 16:27:33 +0100 Subject: [PATCH] Add falback when tags are missing --- packages/inventory/src/api/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/inventory/src/api/index.js b/packages/inventory/src/api/index.js index 35ef2378e7..5f02dae4a7 100644 --- a/packages/inventory/src/api/index.js +++ b/packages/inventory/src/api/index.js @@ -29,11 +29,18 @@ export const mapData = ({ facts = {}, ...oneResult }) => ({ export const mapTags = (data = { results: [] }, { orderBy, orderDirection } = {}) => { if (data.results.length > 0) { - return hosts.apiHostGetHostTags(data.results.map(({ id }) => id), data.per_page, data.page, orderBy, orderDirection) - .then(({ results: tags }) => ({ - ...data, - results: data.results.map(row => ({ ...row, tags: tags[row.id] || [] })) - })); + return hosts.apiHostGetHostTags(data.results.map(({ id }) => id), data.per_page, 1, orderBy, orderDirection) + .then(({ results: tags }) => ({ + ...data, + results: data.results.map(row => ({ ...row, tags: tags[row.id] || [] })) + })) + .catch(() => ({ + ...data, + results: data.results.map(row => ({ + ...row, + tags: [] + })) + })); } return data;