title: Downloading and renaming a file in Javascript
body: <p>I want to hit a URL to download a file and rename the file I get as response using javascript. I tried the following code but its not working. The file is getting downloaded but renaming is not happening </p>
  
  <pre><code>function downloadAndRename(url, fileName){
      var anchor = document.createElement('a');
      $('body').append(anchor);
      anchor.href = url;
      anchor.download = fileName;
      anchor.click();
  }
  </code></pre>
  
  <p>Is there any other way by which I can do this? </p>