How to download a file with Node.js (without using third-party libraries)?

后端 未结 28 1249
逝去的感伤
逝去的感伤 2020-11-22 03:37

How do I download a file with Node.js without using third-party libraries?

I don\'t need anything special. I only want to download a file from a giv

28条回答
  •  终归单人心
    2020-11-22 04:05

    I prefer request() because you can use both http and https with it.

    request('http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg')
      .pipe(fs.createWriteStream('cat.jpg'))
    

提交回复
热议问题