You are reading a single comment by @dumdum and its replies. Click here to read the full conversation.
  • a bit more than 5 lines actually

    const app = require('express')();
    
    app.get('/', (req, res) => {
      console.log("fetching ...", req.query.url);
      if (req.query.url) fetch(req.query.url, (data) => {res.send(data); });
      else res.send("missing url");
    });
    
    const port = 9999;
    
    app.listen(port, () => {
      console.log(`fetch a url with http://localhost:${port}?url=https://som­ewhere.com/this-that`);
    });
    
    function fetch(url, cb) {
      require("https").get(url, res => {
        res.setEncoding("utf8");
        let body = "";
        res.on("data", data => { body += data; });
        res.on("end", () => { cb(body); });
      });
    }
    
About

Avatar for dumdum @dumdum started