最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

AWS LAMBDA HTTP POST请求(Node.js的)

运维笔记admin11浏览0评论

AWS LAMBDA HTTP POST请求(Node.js的)

AWS LAMBDA HTTP POST请求(Node.js的)

我是比较新的AWS lambda表达式和的NodeJS。我正在使用本网站的HTTP POST请求,试图让一个国家的5个城市的名单:“.asmx?op=GetCitiesByCountry”

我一直在寻找如何做拉姆达功能的HTTP POST请求,但我似乎无法找到它一个很好的解释。

搜索,我发现了HTTP POST:

How to make an HTTP POST request in node.js?

回答如下:

尝试下面的示例,调用HTTP GET或在从AWS拉姆达的NodeJS POST请求

const options = {
        hostname: 'hostname',
        port: port number,
        path: urlpath,
        method: 'method type'
    };

const req = https.request(options, (res) => {
    res.setEncoding('utf8');
    res.on('data', (chunk) => {
      // code to execute
    });
    res.on('end', () => {
      // code to execute      
    });
});
req.on('error', (e) => {
    callback(null, "Error has occured");
});
req.end();

考虑样本

发布评论

评论列表(0)

  1. 暂无评论