I am trying to Post a json to my flask server, but the post request always fails. This is how I am doing it, any idea what is am doing wrong?
jQuery.ajax({
url:'/someLink',
method:'POST',
data:JSON.stringify({"sampleKey":"Value"}),
success:function(data){
console.log(data);
},
});
And my flask server looks something like
@app.route('/someLink', methods=['POST'])
def someFn():
sampleKey = str(request.form['sampleKey'])
I believe there is some data serializing issue, as the following request works
jQuery.post('/someLink',{"sampleKey":"Value"},function(data){console.log(data)});