Created
June 10, 2021 15:16
-
-
Save owrrpon/846a0b3c761a26504a26fd95f23eca06 to your computer and use it in GitHub Desktop.
Angular API File Download
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { saveAs } from 'file-saver'; | |
... | |
downloadFile(){ | |
return this.serviceWrapper( | |
'POST', | |
this.getAPI('file_download'), | |
(response: any) => { | |
let file_name = "dummy_file.pdf"; | |
saveAs(response, file_name); | |
return {'data': {'message': 'download success'}}; | |
}, | |
{ | |
body: { | |
'dummy': 'data' | |
}, | |
responseType: "blob" | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment