Nextjs13 app dir, sequentially running requests doesnt work during building process
Unanswered
Bartholomeas posted this in #help-forum
Hello, as in title.
Im getting entire objects from that url (thats my individual api, not next route):
From that endpoint im getting array of objects like that:
Then in this promise.all im sending request for every object to get image url from
Im getting entire objects from that url (thats my individual api, not next route):
export const getKnowledgeBaseLandingArticles = async (): Promise<TPaginatedReturnType> => {
const params = new URLSearchParams({
Page: '1',
Results: '3',
})
const url = `${API_URL}/knowledge-base/articles/published?${params.toString()}`
try {
const res = await fetch(url)
if (!res.ok) {
throw new Error('getKnowledgeBaseLandingArticles: response is invalid')
}
return (await res.json()) as TPaginatedReturnType
} catch (err) {
throw new Error(`getKnowledgeBaseLandingArticles: ${err}`)
}
}From that endpoint im getting array of objects like that:
[ {
id: '70c0we4e5-e511-4b62-b739-fdf8e8305e96',
title: 'title',
shortDescription: ' shortdescrt.',
createdAt: '2023-01-10T11:10:52.605937',
categoryCode: 'Pigeons',
category: { code: 'Pigeons', name: 'Gołebie' },
thumbnailId: 'asd8asd8382d938d729348d79',
isPublish: null
}]Then in this promise.all im sending request for every object to get image url from
thumbnailId, this endpoint looks like that: import { TApiFile } from 'api-pigener/other/documents/getFile'
import { API_URL } from 'misc/config/env'
export const getStaticFile = async (fileId: TApiFile['id']): Promise<TApiFile> => {
if (!fileId)
return Promise.reject(new Error('getStaticFile: fileId is undefined or null').message)
try {
const res = await fetch(`${API_URL}/documents/${fileId}`)
if (!res.ok) {
throw new Error('getStaticFile: response is invalid')
}
return res.json() as any
} catch (err) {
throw new Error(`getStaticFile: ${err}`)
}
}8 Replies
and from return im getting array of objects like that:
[ {
id: '70c0we4e5-e511-4b62-b739-fdf8e8305e96',
title: 'title',
shortDescription: ' shortdescrt.',
createdAt: '2023-01-10T11:10:52.605937',
categoryCode: 'Pigeons',
category: { code: 'Pigeons', name: 'Gołebie' },
thumbnailId: ,
isPublish: null
}]@Bartholomeas and from return im getting array of objects like that:
jsx
[ {
id: '70c0we4e5-e511-4b62-b739-fdf8e8305e96',
title: 'title',
shortDescription: ' shortdescrt.',
createdAt: '2023-01-10T11:10:52.605937',
categoryCode: 'Pigeons',
category: { code: 'Pigeons', name: 'Gołebie' },
thumbnailId: ,
isPublish: null
}]
I have no idea why during develop everything is great, but when im building pages, and then serve it im getting objects with thumbnailId as null as you can see here
can you show the error log?
I do not get any errors :/
Im getting this during development:
Its correct url to my image
but wait a sec, ill send from build process to
and that during build