text: const http = require("http");
  const fs = require("fs");
  
  function download(url, dest) {
      return new Promise((resolve, reject) => {
          const file = fs.createWriteStream(dest, { flags: "wx" });
  
          const request = http.get(url, response => {
              if (response.statusCode === 200) {
                  response.pipe(file);
              } else {
                  file.close();
                  fs.unlink(dest, () => {}); // Delete temp file
                  reject(`Server responded with ${response.statusCode}: ${response.statusMessage}`);
              }
          });
  
          request.on("error", err => {
              file.close();
              fs.unlink(dest, () => {}); // Delete temp file
              reject(err.message);
          });
  
          file.on("finish", () => {
              resolve();
          });
  
          file.on("error", err => {
              file.close();
  
              if (err.code === "EEXIST") {
                  reject("File already exists");
              } else {
                  fs.unlink(dest, () => {}); // Delete temp file
                  reject(err.message);
              }
          });
      });
  }
  download('http://rate.bot.com.tw/xrt/flcsv/0/day','a.csv')