I have an upload button which, after uploading the file, creates a property in my object adding its url.
All working well in the editor, but when I go live (chrome dev console), I get the error:
Cannot create property ‘justificantePago’ on string ‘[object Object]’.
I’m logging the file url and it’s the following:
wix:document://v1/34f7fa_e5a69265700743489ad17741f17bae6a.pdf/B1-Juliol 2019 .pdf
My code is:
$w('#enviar').onClick(() => {
$w('#pujaJust').startUpload().then((file) => {
//infoTrans is an object
let infoTrans = session.getItem('infoTransAlumne');
//Adding the property. Getting error here.
console.log(file.url)
infoTrans['justificantePago'] = file.url;
//Guardem dades transacció
wixData.insert('pagosMatricula', infoTrans).then(()=>{console.log('insertado')}, error=>{console.error(error.message)});
})
.catch(err => {
console.warn(err.message);
$w('#errorText').text = 'Error al pujar el justificant. Per favor, torna a intentar-ho.'
$w('#errorText').show('fade', { 'delay': 2000 });
})
})
Which is a regular url of a wix document.
Any ideas?
Thank you in advanced!!