I am trying to send an array from my javascript client to my flask server. I can log the array right before the ajax post-call and see that it exists and looks right. However, when I print it on the flask server-side I receive an empty string.
I have tried 2 different versions of javascript to post it:
Here is the first
$.post("/javamongo", {
data: JSON.stringify(data)
}, function(err, req, resp){
window.locationhref = "/results/"+resp["responseJSON"]["uuid"];
})
here is the second
$.ajax({
url: '/javamongo',
type: "POST",
ContentType: 'application/json',
data: {'data': data}
}).done(function(data) {
console.log(data);
});
Both are producing different versions of empty when they are received. On my flask server I have tried:
data = request.data
and
data = request.data.decode("utf-8")
as well as passing those through JSON.loads() all to no avail.
Any advice or help would be greatly appreciated!