From 4ea588f9fd2629642f03c7e871d753451a49fc5b 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/inventory/src/api/index.js b/packages/inventory/src/api/index.js index 35ef2378e..29aff7cc7 100644 --- a/packages/inventory/src/api/index.js +++ b/packages/inventory/src/api/index.js @@ -29,10 +29,17 @@ 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) + 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: [] + })) })); }