Upload a file to Xano with custom JavaScript - WeWeb error

Thank you for the input, @dorilama. It turns out, the issue wasn’t necessarily the selector, but rather, trying to use the selector within the workflow editor.

I recorded a ~2 minute video explaining what happened here. It looks like this may be a bug caused by the new workflow editor. :thinking:

If it’s helpful to others, I found setting up quite a few console.log statements along the way really helpful to debug this. I also received help to adjust the code towards the bottom as I received a different error with the default code. I’ll leave that code below with the comments and with my API endpoint removed.

// console.log("starting");
var formData = new FormData();
var imagefile = document.querySelector('#verUpload input');
// console.log("imagefile is ",imagefile,imagefile.files);

// console.log("file 0 is ",imagefile.files[0]);

formData.append("content", imagefile.files[0]);
console.log("formData is ",formData);
var result = axios.post("your-xano-endpoint.com/upload/etc", formData,{
    headers:{
        "Content-Type": "multipart/form-data"
    }
})
// console.log("result is ",result);
var waitResponse = await result;
// console.log("waitResponse is",waitResponse);
return waitResponse
2 Likes