Skip to content

Commit

Permalink
CORE: log issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ekachxaidze98 committed Jan 29, 2025
1 parent d5063ce commit 0c838d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions pages/search/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,22 @@ export const getServerSideProps = async ({ query: searchParams }) => {
try {
const response = await fetchWorks(body)

const transformedWorks = await Promise.all(
response?.results?.map(async (work) => {
const articleWithUrls = findUrlsByType(work)
return {
...articleWithUrls,
dataProviders: await transformDataProviders(work.dataProviders),
}
})
)
if (response?.results) {
const transformedWorks = await Promise.all(
response.results.map(async (work) => {
const articleWithUrls = findUrlsByType(work)
return {
...articleWithUrls,
dataProviders: await transformDataProviders(work.dataProviders),
}
})
)

Object.assign(data, {
...response,
results: transformedWorks,
})
Object.assign(data, {
...response,
results: transformedWorks,
})
} else data.results = []
} catch (error) {
log(error)
const queryError = {
Expand Down
2 changes: 1 addition & 1 deletion templates/data-provider/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const DataProviderTemplate = ({ data, onSearch, className, ...restProps }) => {
className={styles.sort}
/>
</div>
<Results works={outputs.results} />
<Results works={outputs?.results || []} />
{outputs.data && outputs.data.length === 0 && outputs.error == null && (
<div className={styles.noResultsFound}>
This data provider has not articles yet.
Expand Down

0 comments on commit 0c838d1

Please sign in to comment.