Hello,
So I got a dedicated server that I use to send values to, it will generate a spreadsheet (XLSX). And i get the return
Response from the server, i know this is correct and its the XLSX file.
back and code below
import { fetch } from 'wix-fetch';
export function sendDataToServer(eventName, date, location, teams) {
const url = "what ever floats your boat.com";
// const data = {
// eventName: eventName,
// date: date,
// location: location,
// teams: teams
// };
const data = {
eventName: 'eventName',
date: 'date',
location: 'location',
teams:'teams'
};
return fetch(url, {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.text())
.catch(error => console.error('Error:', error));
}
Front end code:
import { sendDataToServer } from 'backend/CRON.jsw';
$w.onReady(function () {
$w("#button1").onClick(async () => {
let eventName = $w("#eventName").value;
let date = $w("#date").value;
let location = $w("#location").value;
let teams = $w("#teams").value;
try {
let downloadURL = await sendDataToServer(eventName, date, location, teams);
if (downloadURL) {
$w("#downloadFrame").src = downloadURL; // This will trigger the file to be downloaded
} else {
console.error("No download URL found in response");
}
} catch (error) {
console.error("Error sending data:", error);
}
});
});
I try to create a HTML insert and prompt it to download through there. I try to have a document element and upload it into that and then promp an download, but a simple promp/ instant download to user i cant get it to work
But now I can’t get a prompted to get it downloaded on Wix… How do I get this file to download to the user, i don’t want to store the file as it’s not needed for me to keep on the server.
thanks!