Hello to all! I am facing a problem: I have to make a request to my own server after submitting the form, and for that I need to submit the url of the uploaded file. When I make a request without the '$w('# fileUpload').StartUpload()' function, everything is fine and I get a success message. But when I try to upload a file and wait for the promise to resolve with the file url, I get an error. The strange thing is that the developer console is clean and all requests have a status of 200. I want to get a success message in this case too. Below is my code that handles the submit form -
export async function onSubmitClick(event) {
const uploadFile = async () => {
const uploadedFile = await $w('# fileUpload').startUpload();
const fileUrl = await getFileUrl(uploadedFile);
return fileUrl;
}
const firstName = $w('# firstName').value || ''
const lastName = $w('# lastName').value || ''
const company = $w('# company').value || ''
const email = $w('# email').value || ''
const description = $w('# description').value || ''
const website = $w('# website').value || ''
const amount = $w('# amount').value || 0
const businessStarted = $w('# business').value || ''
const targetIndustry = $w('# targetIndustry').value || ''
const teamCountry = $w('# teamCountry').value || ''
const lastMonthRevenue = $w('# lastMonthRevenue').value || ''
const b2b = $w('# b2b').value || ''
const legalEntityCountry = $w('# legalEntityCountry').value || ''
const file = $w('# fileUpload');
const url = 'APIurl';
const data = {
'company. amount': amount,
'company. name': company,
'company. email': email,
'company. website': website,
'company. fundId': 'fundId',
'company. description': description,
'persons. firstName': firstName,
'persons. lastName': lastName,
businessStarted,
targetIndustry,
teamCountry,
lastMonthRevenue,
b2b,
legalEntityCountry,
fileUrl: file. value. length ? await uploadFile() : null
};
try {
axios. post(url, data, { headers: {
'X-Api-Key': 'APIkey'
} });
} catch(error) {
console.log('ERROR: ', error);
}
}
![](https://static.wixstatic.com/media/a27d24_d4bb25e380fd421ab7dd05ea3b9ace5b~mv2.png/v1/fill/w_980,h_530,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/a27d24_d4bb25e380fd421ab7dd05ea3b9ace5b~mv2.png)