I am trying to send a form with an upload button and text fields. My problem is that I don’t think I can send emails via sendgrid, so I was thinking of just sending the url of the uploaded image.
Here’s my code at the moment…
import {sendEmail} from ‘backend/email’;
import wixLocation from ‘wix-location’;
export function submitButton_click(event) {
sendFormData();
}
function upfile() {
if($w(“#IconOrElement”).value.length > 0) {
$w(“#IconOrElement”).startUpload()
.then( (uploadedFile) => {
let uploadfileurl = uploadedFile.url;
console.log("test in upfile: " + uploadedFile.url);
let upString = uploadfileurl.split("/");
console.log(upString[3]);
return upString;
}); //End of then
}
}
function sendFormData() {
let uf = upfile();
console.log("test 3 outside upfile: " + uf);
var subject = "Logo Discovery Form Submission: ";
var body = `Company or Product: ${$w("#CompanyOrProduct").value}
\rIconOrElement: ` + uf +
`\r\rCompetitor Website: ${$w("#CompetitorWebsite").value}
\rAdditional Information: ${$w("#AdditionalInformation").value}`;
sendEmail(subject, body);
return true;
}
So yeah, it keeps just returning an undefined value for “upString”, when I want it to be the url to the uploaded image. I tried putting the var subject, var body and sendEmail(subject,body); in the .then, but it then doesn’t show the ${$w(“#CompetitorWebsite”).value or ${$w(“#AdditionalInformation”).value
How do you retrieve the uploadFile.url from a .then?