Reputation:
I have a very simple and straightforward code:
Py:
@blueprint.route('/Ajax', methods=['GET', 'POST'])
def Ajax():
Graph1 = [10,10,10,10,10]
return jsonify(Graph1)
JS
fetch('/Ajax')
.then(function (response) {
theData = Object.values(response);
console.log(theData);
return theData;
})
Yet I am getting:
I am not sure why this is the reason.
Upvotes: 0
Views: 327
Reputation: 6313
I'm unsure about your Python code but with fetch
in js you need to convert the response to json
first.
This should work:
fetch('/Ajax')
.then(response => response.json()) // <--- this has been added
.then(function (response) {
theData = Object.values(response);
console.log(theData);
return theData;
});
Upvotes: 1