Skip to main content

max / makenotwork

434 B · 14 lines History Blame Raw
1 function downloadVersion(versionId) {
2 fetch('/api/versions/' + versionId + '/download')
3 .then(function(res) {
4 if (!res.ok) throw new Error('Failed to get download URL');
5 return res.json();
6 })
7 .then(function(data) {
8 window.location.href = data.download_url;
9 })
10 .catch(function(err) {
11 showToast(err.message || 'Download failed');
12 });
13 }
14