【问题标题】:Where can I pass POST data to an api using meteor http?我在哪里可以使用流星 http 将 POST 数据传递给 api?
【发布时间】:2015-11-17 15:25:00
【问题描述】:

我目前的代码如下:

HTTP.post("http://httpbin.org/post", {},

        function(error, results) {
            if (results) {
                console.log(results);
            } else {
                console.log(error)
            }
        }
    );

那么,如果我想发布一些 json 数据,我应该在哪里传递呢?我试图将它作为第二个参数传递给我的 http post 方法,但它不起作用,还请告诉我在哪里输入 api 密钥?

谢谢

【问题讨论】:

    标签: javascript json api meteor


    【解决方案1】:

    简单

        var data = {
           key: value,
           key2: value2
        };
        var headers = {
    
        };
        var res = HTTP.post(url, { data: data, headers: headers });
    

    查看文档以获取更多选项http://docs.meteor.com/#/full/http_call

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-07
      • 1970-01-01
      • 2018-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 2013-02-28
      相关资源
      最近更新 更多