How is an HTTP POST request made in node.js?

后端 未结 21 2404
南方客
南方客 2020-11-21 23:54

How can I make an outbound HTTP POST request, with data, in node.js?

21条回答
  •  天涯浪人
    2020-11-22 00:26

    I use Restler and Needle for production purposes. They are both much more powerful than native httprequest. It is possible to request with basic authentication, special header entry or even upload/download files.

    As for post/get operation, they also are much simpler to use than raw ajax calls using httprequest.

    needle.post('https://my.app.com/endpoint', {foo:'bar'}, 
        function(err, resp, body){
            console.log(body);
    });
    

提交回复
热议问题