📌  相关文章
📜  Javascript - 在 localhost 上使用 fetch 和 URL 参数 [关闭] - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:18.756000             🧑  作者: Mango

代码示例1
//As per Quention's advice, I needed to add http:// in front of localhost:3001. The code became:

const url = new URL("http://localhost:3001")

//Afterwards, I needed to enable cors on my server in order to fix another error.

//Because I was using express, I just ran npm install cors and then added the following 2 lines to my server:

//use it in top your Express app

const cors = require("cors")
app.use(cors())