kreangkrai

Untitled

Apr 20th, 2019
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {saveAs} from 'file-saver';
  2.  
  3.  
  4.  
  5.    downloadFileService(url,opts){
  6.         return this._http.get(url,opts,{
  7.             responseType : 'blob',
  8.             headers:new HttpHeaders().append('Content-Type','application/json')
  9.         });
  10.     }
  11.  
  12.     downloadFile(){
  13.         downloadFileService('url','options').subscribe((resp)=>{
  14. saveAs(resp,'filename.txt')
  15.         },(err)=>{
  16.             console.log('downloadFile erro',err);
  17.         })
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment