使用nodejs尽快完成1000个帖子的请求。

问题描述 投票:-3回答:1

其实,我想用nodejs尽快做出1000个帖子的请求,比较想知道,如何才能实现,所以我是nodejs的新手,如何才能做到呢?

谁能给我一条正确的道路

node.js
1个回答
0
投票

把请求放在一个循环里面就可以了。看一下文档中的 httphttps.

const https = require("https");

for (let i=0; i<1000; i++) {
  const req = https.request({
    method: "POST",
    // Other request options
  }, resp => {
    // Handle the response, if you need
  });
  // If you need to send data, you can use `req.write()`
  req.end();
}
© www.soinside.com 2019 - 2024. All rights reserved.