From 7710681398f499f5a83c4b7c47b025cf960587a3 Mon Sep 17 00:00:00 2001 From: Aman Kalra <44301957+aman97kalra@users.noreply.github.com> Date: Sat, 3 Oct 2020 14:02:18 +0530 Subject: [PATCH] Passed parameters as objects. --- imageDownloader.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/imageDownloader.js b/imageDownloader.js index 3e33fc5..0d66d91 100644 --- a/imageDownloader.js +++ b/imageDownloader.js @@ -5,7 +5,7 @@ const https = require('https'); * @param {*} url url of the image to be downloaded * @param {*} path path where the image is be saved. */ -function saveImageToDisk( url, path ){ +function saveImageToDisk( { url, path } ){ var fullUrl = url; var localPath = fs.createWriteStream(path); try{ @@ -18,5 +18,4 @@ function saveImageToDisk( url, path ){ } }; -saveImageToDisk('https://random.dog/vh7i79y2qhhy.jpg', -'./image.jpg'); +saveImageToDisk( { url: 'https://random.dog/vh7i79y2qhhy.jpg', path: './image.jpg' } );