【发布时间】:2021-08-25 17:07:06
【问题描述】:
这是我的 getTopGifts 函数:
export async function getTopGifts() {
const data = [{"id":1,"title":"test"}]
return data
}
但是当我使用上面的函数时出现错误:
export async function getStaticProps() {
// fetch list of gifts
const gifts = getTopGifts()
console.log(typeof(_gifts))
return {
props: {
gifts: gifts
},
}
}
我的错误:
Error: Error serializing `.gifts` returned from `getStaticProps` in "/gifts".
Reason: `object` ("[object Promise]") cannot be serialized as JSON. Please only return JSON serializable data types.
【问题讨论】:
标签: javascript next.js