I wrote a JS program that sends arguments to a flask server and prints the returned value in the console. The server returns either [0]
or [1]
depending on the arguments sent.
However, when this program sends arguments to the server, the resultant fetch() data attribute is always an empty dict {}
instead of [0]
or [1]
. Why is this? In Chrome DevTools, in the Network section, it shows the expected response, but this isn't reflected in fetch()'s data attribute
Code:
function predict(values) {
fetch(`https://darrendube.pythonanywhere.com/?${stringify(values)}`)
.then((response) => JSON.stringify(response))
.then((data) => console.log(data))
}
What is printed in the console:
What is shown in Chrome DevTools (and the value I expect):
The fact that DevTools shows the expected response means that the arguments are correct and the server is working normally, so there must be a mistake in my code...
What could it be?