Rahul Khatri
Rahul Khatri

Reputation: 287

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

my current code is as follows:

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

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

So, if I want to post some json data, where do I pass it? I was trying to pass it as the second argument to my http post method but it wont work and please also do tell me that where do I enter the api keys?

Thanks

Upvotes: 0

Views: 45

Answers (1)

Sasikanth
Sasikanth

Reputation: 3043

Simple

    var data = {
       key: value,
       key2: value2
    };
    var headers = {

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

check docs for more options http://docs.meteor.com/#/full/http_call

Upvotes: 1

Related Questions