尝试使用 NextJS 上的 getStaticProps 从 firebase 获取数据时,我收到错误 XMLHttpRequest is not defined

问题描述

所以,我试图获取我的数据库的 videoPaths,并得到那个错误,这就是代码,我在 stackoverflow 的另一篇文章中得到了它

export const getStaticProps = async () => {
let videos = [];
 try {
   const querySnapshot = await firebase
  .firestore()
  .collection('allVideos')
  .get();

querySnapshot.forEach(function (doc) {
  console.log(doc.data().title);
  console.log(doc.data().pid);
  videos.push({
    pid: doc.data().pid,title: doc.data().title,});
});
} catch (error) {
 console.log('Error getting documents: ',error);
}

return {
  props: {
    videos,},};
};

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)