Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i got a js request to my postgresql database, i'm trying to make a registration. I tried to send react state before that, but now i just filled it up with constant values.

It send an empty body. Body: null. GET request works, the problem happens only when i use POST request

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"
   })
 })
question from:https://stackoverflow.com/questions/65643572/fetching-data-react-js

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
75 views
Welcome To Ask or Share your Answers For Others

1 Answer

UPD: the problem was solved, i've installed cors package and added app.use(cors()); into my backend code (node.js). also you have to delete no cors mode


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...