mirror of
https://github.com/strapi/strapi.git
synced 2025-12-13 16:08:11 +00:00
normalizeRelations: Return empty array as fallback
This commit is contained in:
parent
6d1642d713
commit
3e90c71ead
@ -6,16 +6,12 @@ export const normalizeRelations = (
|
||||
relations,
|
||||
{ modifiedData = {}, shouldAddLink = false, mainFieldName, targetModel }
|
||||
) => {
|
||||
// TODO
|
||||
if (!relations?.data?.pages) {
|
||||
return relations;
|
||||
}
|
||||
|
||||
return {
|
||||
...relations,
|
||||
data: {
|
||||
pages: relations.data.pages
|
||||
.map((page) => [
|
||||
pages:
|
||||
relations?.data?.pages
|
||||
?.map((page) => [
|
||||
...[...page.results, ...(modifiedData?.connect ?? [])]
|
||||
.map((relation) => {
|
||||
const nextRelation = { ...relation };
|
||||
@ -42,8 +38,8 @@ export const normalizeRelations = (
|
||||
})
|
||||
.filter(Boolean),
|
||||
])
|
||||
.filter((page) => page.length > 0)
|
||||
.reverse(),
|
||||
?.filter((page) => page.length > 0)
|
||||
?.reverse() ?? [],
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user