Skip to content
Advertisement

express post request body shows up as empty

server code

JavaScript

client code

JavaScript

terminal shows: {} tried pretty much everything so help would be very much appreciated thanks in advance:)

Advertisement

Answer

You said mode: 'no-cors' which tells fetch to silently ignore anything which requires CORS permission.

Setting the Content-Type to application/json requires CORS permission so your request is sent with Content-Type: text/plain instead.

This doesn’t trigger the JSON body parser.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement