G
G
Galdar Turin2020-01-29 08:57:32
Node.js
Galdar Turin, 2020-01-29 08:57:32

What am I doing wrong when downloading the file?

Good afternoon, I want to download a file from Rossvyaz, but it's just being created and that's it, I found a lot of information about this, but I still can't understand why it doesn't want to download the file?

let fs      = common.fs;    
    let http    = common.http;

    var download = function(url, dest, cb) {
        var file = fs.createWriteStream(dest);
        var request = http.get(url, function(response) {
          response.pipe(file);
          file.on('finish', function() {
            file.close(cb);
          });
        });
    }
    download("http://rossvyaz.ru/data/DEF-9xx.csv", "./_temp/def.csv", "");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-01-29
@notiv-nt

const fs = require('fs');
const http = require('https');

var download = function(url, dest, cb) {
  var file = fs.createWriteStream(dest);
  var request = http.get(url, function(response) {
    response.pipe(file);
    file.on('finish', function() {
      file.close(cb);
    });
  });
};
download('https://rossvyaz.ru/data/DEF-9xx.csv', './def.csv', '');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question