Skip to content

Instantly share code, notes, and snippets.

View Moro-Code's full-sized avatar
🎄
Advent of Code 2024!

Omar Nasr Moro-Code

🎄
Advent of Code 2024!
View GitHub Profile
@Moro-Code
Moro-Code / download-file.js
Created September 8, 2022 03:01 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);