I am learning JavaScript, and I am making an account log-in page as a learning project. The server is using Python's Flask. The fetch function doesn't seem to be working as I want it to. For one, it is sending an options request instead of a POST, even though I specified POST. Another thing is that the server isn't receiving the data, it comes up as blank. Here is the code:
var content = JSON.stringify({'username': username, 'password': password}) //username and password are user inputs, I had them print and these work fine.
var response = fetch(url+"/api/login", {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: content
})
.then(response => {
console.log("Success") //this doesn't print.
})