[英]Reference error: data is undefined next js
I'm a newbie in react.我是反应新手。 I used getStaticprops to fetch data from an api.
我使用 getStaticprops 从 api 获取数据。 I'm creating a filter gallery.
我正在创建一个过滤器库。 Now when I tried to access the {props: data} outside the blog function it shows an error.
现在,当我尝试访问博客 function 之外的 {props: data} 时,它显示错误。 Reference Error: data is not defined.
参考错误:数据未定义。
Now how can I use data outside my blog function?现在如何在我的博客 function 之外使用数据? I'll be very thankful if anyone help me with this.
如果有人帮助我,我将非常感激。 Thanks in advance.
提前致谢。
You need to run你需要跑
let data = await getStaticProps();
const allSugg...
in blog function before return在博客 function 之前返回
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.