Ask coding questions

← Back to all posts
how do you do a POST request in JS
Mathman05 (1)

I've been trying to do a POST request to https://tetris-serverside.mathman05.repl.co/set/"+id but it gives me an error "TypeError: Failed to execute 'fetch' on 'Window': Invalid name" I'm trying to use fetch

fetch("https://tetris-serverside.mathman05.repl.co/set/"+id, {
  method: 'POST',
  headers: {
    'the board': true
  },
  body: exportT()
}).then((g)=> {})
.catch(console.error);

(the headers aren't needed in this situation if that helps)

Answered by themining72 (49) [earned 5 cycles]
View Answer
Comments
hotnewtop
themining72 (49)

I don't think spaces are allowed, try changing your code to:
'theboard': true