mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 00:09:18 +00:00
useRelation/ normalizeRelations: Handle 204 response code properly
This commit is contained in:
parent
16efdef61c
commit
9e4433f881
@ -12,7 +12,7 @@ export const normalizeRelations = (
|
||||
pages:
|
||||
relations?.data?.pages
|
||||
?.map((page) => [
|
||||
...[...page.results, ...(modifiedData?.connect ?? [])]
|
||||
...[...(page?.results ?? []), ...(modifiedData?.connect ?? [])]
|
||||
.map((relation) => {
|
||||
const nextRelation = { ...relation };
|
||||
|
||||
|
@ -40,7 +40,8 @@ export const useRelation = (cacheKey, { relation, search }) => {
|
||||
const relationsRes = useInfiniteQuery(['relation', cacheKey], fetchRelations, {
|
||||
enabled: !!relation?.endpoint,
|
||||
getNextPageParam(lastPage) {
|
||||
if (lastPage.pagination.page >= lastPage.pagination.pageCount) {
|
||||
// the API may send an empty 204 response
|
||||
if (!lastPage || lastPage.pagination.page >= lastPage.pagination.pageCount) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user