Does koa require get to request that other servers can only use native http?

app.use(async ctx => {
  console.log("ctx",ctx)  
  if ("/qsonhs.aspx" == ctx.path) {
    http
      .get("http://nodejs.cn/index.json", res => {
        const { statusCode } = res;
        const contentType = res.headers["content-type"];

        let error;
        if (statusCode !== 200) {
          error = new Error("\n" + `: ${statusCode}`);
        } else if (!/^application\/json/.test(contentType)) {
          error = new Error(
            " content-type.\n" +
              ` application/json  ${contentType}`
          );
        }
        if (error) {
          console.error(error.message);
          // 
          res.resume();
          return;
        }

        res.setEncoding("utf8");
        let rawData = "";
        res.on("data", chunk => {
          rawData += chunk;
        });
        res.on("end", () => {
          try {
            const parsedData = JSON.parse(rawData);
            console.log(parsedData);
          } catch (e) {
            console.error(e.message);
          }
        });
      })
      .on("error", e => {
        console.error(`: ${e.message}`);
      });
  }
});
Apr.14,2022

you can use third-party libraries, axios or request

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bac9-2c2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bac9-2c2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?