Thursday, March 9, 2023
HomeSoftware EngineeringHow one can Obtain a File in NodeJS with none Third Celebration...

How one can Obtain a File in NodeJS with none Third Celebration Libraries


If you want to obtain a file in NodeJS with out utilizing any third celebration libraries, then you are able to do the next.

The NodeJS ecosystem comes with a fs module, that is to indicate the FileSystem in-built library.

First declare your imports:

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

Now you need to use the https module to obtain a file, and write it to a stream utilizing fs.

const https = require("https");
const fs = require("fs");
 
const endpoint = "https://instance/information/some_csv_file";
 
https.get(endpoint, (res) => {
  const file_name = "the_csv.csv";
  const writeStream = fs.createWriteStream(file_name);
});

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments