[英]Next.js/Square API error: Fetch API cannot load. URL scheme "webpack-internal" is not supported
I'm having this error when trying to pull stock from Square API.尝试从 Square API 提取库存时出现此错误。
injectGlobalHook.js:1648 Fetch API cannot load webpack-internal:///./node_modules/@next/react-dev-overlay/lib/internal/ReactDevOverlay.js. URL scheme "webpack-internal" is not supported.
I'm converting my React.js project into Next.js, so I'm just trying to learn the differences between the two.我正在将我的 React.js 项目转换为 Next.js,所以我只是想了解两者之间的差异。
Initially, I pulled the data with a proxy
in my config
file to avoid a CORS Error
, but knew that was just a workaround for the time being because I needed to hide the API_KEY
.最初,我使用
config
文件中的proxy
提取数据以避免CORS Error
,但我知道这只是暂时的解决方法,因为我需要隐藏API_KEY
。
Now I'm trying to call the API the right way in Next.js backend options with getServerSideProps
现在我正在尝试使用
getServerSideProps
在 Next.js 后端选项中以正确的方式调用 API
export async function getStaticProps() {
const allStockObjects = await fetch(requests.fetchAllStock, {
method: "GET",
headers: headers,
})
.then((res) => res.json)
.catch((err) => console.log(err));
return {
props: {
allStockObjects,
},
};
}
Here is my export, but I have the exact same export in a Component with a POST
request done the same way to the same Square API and it works perfectly fine.这是我的导出,但我在一个组件中有完全相同的导出,
POST
请求以相同的方式完成到相同的 Square API,它工作得非常好。
I also check my APILogs
on my Square Dashboard and the request never makes it to the API at all.我还在 Square Dashboard 上检查了我的
APILogs
,但请求根本没有发送到 API。
Not much online on this error or Square API for that matter, so I hope someone could help.关于此错误或 Square API 的在线信息并不多,所以我希望有人能提供帮助。
I just ran into a similar issue.我刚刚遇到了类似的问题。 For reference I am taking Wes Bos's course on React/ GraphQL.
作为参考,我正在学习 Wes Bos 的 React/GraphQL 课程。 To get past the issue I shut down the frontend and then deleted the .next folder.
为了解决这个问题,我关闭了前端,然后删除了 .next 文件夹。 Then re-ran the frontend so a new .next folder gets generated.
然后重新运行前端,以便生成一个新的 .next 文件夹。 I also cleared the browser cache.
我还清除了浏览器缓存。 After that the issue went away for me.
在那之后,这个问题对我来说就消失了。
这个问题是由 React Devtoools 引起的,特别是设置Always parse hook names from source (may be slow)
——如果你在不需要时关闭它,它将防止错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.