I am getting an empty [ ] when i hit generate:
127.0.0.1 - - [18/Oct/2019 01:04:37] "POST / HTTP/1.1" 200 - []
Here's the array & JSON in JS:
var List = [
{ load: "2", location: "3" },
{ load: "2", location: "4" },
{ load: "2", location: "8" },
];
document.querySelector('#generate').addEventListener('click',function() {
var json_list = JSON.stringify(List)
$.ajax({
type: "POST",
contentType: "application/json;charset=utf-8",
url: "/",
traditional: "true",
data: json_list,
dataType: "json"
});
})
And here is the code in Flask:
@app.route('/',methods =['GET','POST'])
def index():
req = request.get_json()
print(req)
return render_template("index.html")
However, if i send a array of just numbers, no objects inside (eg. [2,3,4,5]) I actually get the array on my python terminal. So what should I add for the objects to go through?
Edit: When I jsonify the input in flask i get: Response 86 bytes [200 OK]