[英]Fetching data (React.js)
i got a js request to my postgresql database, i'm trying to make a registration.我收到了对我的 postgresql 数据库的 js 请求,我正在尝试进行注册。 I tried to send react state before that, but now i just filled it up with constant values.
在此之前我尝试发送反应 state,但现在我只是用常量值填充它。
It send an empty body.它发送一个空的身体。
Body: null
. Body: null
。 GET
request works, the problem happens only when i use POST
request GET
请求有效,问题仅在我使用POST
请求时发生
const response = await fetch("http://localhost:8080/api/user", {
method: "POST",
mode: 'no-cors',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"username": "lpkopjp",
"email": "mimiomo@mail.ru",
"password": "12345678",
"repeat_password": "12345678"
})
})
UPD: the problem was solved, i've installed cors package and added app.use(cors());
UPD:问题已解决,我已经安装了 cors package 并添加了
app.use(cors());
into my backend code (node.js).进入我的后端代码(node.js)。 also you have to delete
no cors mode
你也必须删除
no cors mode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.