DatoCMS 中的 Fetch API 不会带来所有已发布的帖子
我想从 DatoCMS 获取我所有已发布的博客文章。
事实上,我正在做这个。问题是,当我超过 100 时,它只带来 65...有人知道我做错了什么吗?谢谢
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
const response = await datoManagement.items.all(
{
// nested: true,
filter: {
type: 'blog_model' // you can use models `api_key`s or models IDs
},
page: {
offset: 0,
limit: 500
}
},
{
allPages: true
}
);
console.log(response.length);
res.status(200).send(response);
} catch (error) {
res.status(200).send('no ok');
console.log(error);
}
};
I want to fetch all my published blogposts from DatoCMS.
Actually, I'm doing this. The problem is that it only brings 65 when I have more than 100... does anyone know what I'm doing wrong? thanks
export default async (req: NextApiRequest, res: NextApiResponse) => {
try {
const response = await datoManagement.items.all(
{
// nested: true,
filter: {
type: 'blog_model' // you can use models `api_key`s or models IDs
},
page: {
offset: 0,
limit: 500
}
},
{
allPages: true
}
);
console.log(response.length);
res.status(200).send(response);
} catch (error) {
res.status(200).send('no ok');
console.log(error);
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这个问题,但您是否尝试过计算记录数?只是为了检查是否有可能获得它们。
您还可以再次尝试跳过一些内容,以检查是否可以以某种方式获取所有文章。
更多信息请参见:https://www.datocms.com/docs/content-交付API/分页
I am not sure about the issue but did you try to count the number of records? Just to check if it seems possible to get them.
You could also try some skip, again, to check if it is somehow possible to get all your articles.
More infos here: https://www.datocms.com/docs/content-delivery-api/pagination