Skip to content

Commit

Permalink
Add falback when tags are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala committed Nov 20, 2019
1 parent d21d80e commit 4ea588f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/inventory/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}))
}));
}

Expand Down

0 comments on commit 4ea588f

Please sign in to comment.