Javascript convert response into file download

You are consuming JSON response from an API on client side JS. in both cases you need to What is the quickest way to convert csv files to JSON format?

There can be cases, especially in Single Page Applications, when you have some data in the browser already that you have probably received via an Ajax call 

If the data is in a non-text-based format, such as an image or a PDF document, use If the response is JavaScript, or HTML with a All rights reserved