有几个问题弄不清楚,文档说 rest 应该去请求 https://api.leancloud.cn/1.1/classes/Atmmod
我在 https://leancloud.cn/apionline/ 测试中发现 请求的是
https://leancloud.cn/1.1/classes/Atmmod1

另外也想请教下 node 原生要发 rest 请求,应该用 https 模块吗? 端口 443?

我参考了文档 但是却不成功
getaddrinfo ENOTFOUND api.leancloud.cn/1.1/classes/Atmmod
[Finished in 0.2s]

代码是:

var http = require('https')
var querystring = require('querystring')

var post = function(data) {
  var postData = querystring.stringify(data);

  var options = {
    hostname: 'api.leancloud.cn/1.1/classes/Atmmod',
    port: 80,
    path: '/',
    method: 'POST',
    headers: {
      'X-LC-Id': 'xxx',
      'X-LC-Key': 'yyy',
      'Content-Type': 'application/json',
      'Content-Length': postData.length
    }
  };

  var req = http.request(options, function(res) {
    console.log('STATUS: ' + res.statusCode);
    console.log('HEADERS: ' + JSON.stringify(res.headers));
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      console.log('BODY: ' + chunk);
    });
    res.on('end', function() {
      console.log('No more data in response.')
    })
  });

  req.on('error', function(e) {
    console.log('problem with request: ' + e.message);
  });

  // write data to request body
  req.write(postData);
  req.end();
}

exports.post = post

post({
 'html':'html',
 'sub':'sub',
 'mod':'mod'
})