Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

download file from api vue

// download file from api vue.js with axios
axios({
    url: 'http://localhost:8000/api/get-file',
    method: 'GET',
    responseType: 'blob',
}).then((response) => {
     var fileURL = window.URL.createObjectURL(new Blob([response.data]));
     var fileLink = document.createElement('a');
  
     fileLink.href = fileURL;
     fileLink.setAttribute('download', 'file.pdf');
     document.body.appendChild(fileLink);
   
     fileLink.click();
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native linear gradient 
Javascript :: show hidden element javascript 
Javascript :: how to remove whitespace only from first position of string js 
Javascript :: javascript set property for each object in array of objects 
Javascript :: javascript get 1 hour from now 
Javascript :: include other js files in a js file 
Javascript :: how to remove an object from array in react native 
Javascript :: nested object javascript 
Javascript :: deep merge nested objects javascript 
Javascript :: PayloadTooLargeError 
Javascript :: inheritance in es6 
Javascript :: reactjs get url query params as object 
Javascript :: data type in javascript 
Javascript :: Accessing $route.params in VueJS 
Javascript :: read excel file through nodejs 
Javascript :: npx create-express-api 
Javascript :: javascript arithmetic operators 
Javascript :: jquery each response 
Javascript :: Navigator.pushReplacementNamed parameters 
Javascript :: jsonobject in variable 
Javascript :: javascript storage get set item 
Javascript :: return last two values of array in javascript 
Javascript :: js custom event 
Javascript :: javascript check if object 
Javascript :: javascript hours minutes seconds 
Javascript :: axios send file 
Javascript :: converting strings to numbers 
Javascript :: regex for comments javascript 
Javascript :: create app with a specific react version 
Javascript :: js how to round up 2 decimal places 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =