在哪里可以使用流星http将POST数据传递到api

Where can I pass POST data to an api using meteor http?

本文关键字:数据 api POST 可以使 流星 http 在哪里      更新时间:2023-09-26

我当前的代码如下:

HTTP.post("http://httpbin.org/post", {},
        function(error, results) {
            if (results) {
                console.log(results);
            } else {
                console.log(error)
            }
        }
    );

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

感谢

简单

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

查看文档了解更多选项http://docs.meteor.com/#/full/http_call