Sending data through POST request from a node.js server to a node.js server

前端 未结 2 1783
闹比i
闹比i 2020-12-04 08:35

I\'m trying to send data through a POST request from a node.js server to another node.js server. What I do in the \"client\" node.js is the following:



        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 09:09

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

    Just do the following for executing a POST request:

    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();
    });
    

提交回复
热议问题