流星POST不发送数据

时间:2018-07-13 15:03:47

标签: rest meteor flask meteor-react

METEOR POST呼叫

var postData = {
           "link" : "https://s3-us-west-2.amazonaws.com/dfddf/bhQJ5XDTg28vSr8Py/1531485d.pdf"
    }


      HTTP.call( 'POST', 'http://127.0.0.1:5000/api/add_message/hello', postData, 
         function( error, response ) {

         if ( error ) {
            console.log( error );
         } else {
            console.log( response);

         }
      });

FLASK API

app = Flask(__name__)
CORS(app,headers=['Content-Type'])

@app.route('/api/add_message/<uuid>', methods=['GET','POST'])
def add_message(uuid):
    req_data = request.get_json()
    return jsonify(req_data)

我使用Postman和cURL尝试了相同的方法,都正确返回了传递的对象,但是当使用流星调用时,我得到了NONE:

 request.get_json()

1 个答案:

答案 0 :(得分:0)

通过将对象传递给数据密钥来使其正常工作

{ 

data :{ 
        "link" : "blah"
      } 
}