node https POST

     var https = require('https');
      var str = ''
      console.log(str)
      const options = {
            hostname: '',
            json: true,
            path: '',
            port: 443,
            method: 'POST',
            headers: {
                  'Accept': 'application/json;version=2.0',
                  'Content-Type': 'application/json'
            }
      };
      var post_data = {  };
      var json = JSON.stringify(post_data);
      var req = https.request(options, function (res) {
            res.setEncoding('utf8');
            res.on('data', (d) => {
                  var res = JSON.parse(d);
            })
      })
      req.on('error', (e) => {
            console.log(e)
      })
      req.write(json)
      req.end();

猜你喜欢

转载自blog.csdn.net/weixin_41564885/article/details/86474737
今日推荐