I’m able to get an xlsx file from my rails backend with a GET-Request to “/companies/export_xslx”, now I’m facing the problem of getting the file passed the JSON parser. For every request the console shows “JSON.parse: unexpected character at line 1 column 1 of the JSON data”.
Yes, fetching the file directly without using ember-data is the right idea.
I would suggest not manipulating the DOM from the service. Instead, expose the URL from the service and render the <a> in the more usual way from inside a template.
Also, this example code might not tell the whole story, but I’m not sure I see a reason to fetch the file as a blob only to give people a link to it. Wouldn’t it work the same if you just give them a link to the original URL?
If you’re trying to get the file to download instead of navigating to it, the nicest solution is the download attribute, which works for all our supported browsers except IE11.