0👍
The solution is to return this:
return new HttpResponse(
200,
res.body,
{
"content-type": res.type,
"content-disposition": `attachment; filename="${res.filename}"`
},
false
);
First, I was returning the whole object returned from getListingCSV() as the body of the HttpResponse. I changed that to res.body.
Second, I removed the base 64 encoding since that’s not necessary at all.
Third, I added content-disposition to set the filename appropriately.
Source:stackexchange.com