[英]I am getting CORS error while fetching API from Node JS
I am getting issue while fetching Node API using GET method.我在使用 GET 方法获取节点 API 时遇到问题。 This issue is related to CORS but don't know how to resolve it.
此问题与 CORS 有关,但不知道如何解决。 Here is the screenshot of the error which i am getting.
这是我得到的错误的屏幕截图。
And here is the react code where I am trying to fetch data from API.这是我试图从 API 获取数据的反应代码。
And here is my node API code.这是我的节点 API 代码。
Allow cors from your Node.JS entry file.从您的 Node.JS 入口文件中允许 cors。 npm i cors.Import const cors = require('cors'), With express after asigning express instance to a variable holder.
npm i cors.Import const cors = require('cors'),将 express 实例分配给变量持有者后使用 express。 allow express to use cors.
允许快递使用cors。 app.use(cors())
app.use(cors())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.