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

后端 未结 21 2449
南方客
南方客 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

    You can also use Requestify, a really cool and simple HTTP client I wrote for nodeJS + it supports caching.

    Just do the following:

        var requestify = require('requestify');
    
        requestify.post('http://example.com', {
            hello: 'world'
        })
        .then(function(response) {
            // Get the response body (JSON parsed or jQuery object for XMLs)
            response.getBody();
        });
    

提交回复
热议问题