Sending form data with FormData()

Hello guys!

How can I send a form using new FormData()?

In the forms finish interaction, you can add a run code step and write the JavaScript you want there, including referencing window.formdata

This simply doesn’t work :
const formData = new window.FormData();
formData.append(‘nom’, ‘John’); // Ajoutez les champs de formulaire et leurs valeurs
formData.append(‘email’, ‘john@example.com’);
formData.append(‘fichier’, $state.upload2.files[0]); // Remplacez “fichierBlob” par votre fichier

const config = {
headers: {
‘Content-Type’: ‘multipart/form-data’
}
};

$$.axios.post(‘https://mango.monodon.eu/webhook-test/a49994f2-a11b-4804-ad87-1b5f377c9e2a’, formData, config)
.then(response => {
// Traitement de la réponse
console.log(response.data);
})
.catch(error => {
// Gestion des erreurs
console.error(error);
});

The response I have from the server :
{
“headers”:
{
“host”:
mango.monodon.eu”,
“user-agent”:
“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36”,
“content-length”:
“355”,
“accept”:
“application/json, text/plain, /”,
“accept-encoding”:
“gzip, deflate, br”,
“accept-language”:
“fr;q=0.8”,
“content-type”:
“multipart/form-data; boundary=----WebKitFormBoundaryFHuJA4n9VELfQlQr”,
“origin”:
https://host.plasmicdev.com”,
“referer”:
https://host.plasmicdev.com/”,
“sec-ch-ua”:
"“Brave”;v=“119”, “Chromium”;v=“119”, “Not?A_Brand”;v=“24"”,
“sec-ch-ua-mobile”:
“?0”,
“sec-ch-ua-platform”:
““Windows””,
“sec-fetch-dest”:
“empty”,
“sec-fetch-mode”:
“cors”,
“sec-fetch-site”:
“cross-site”,
“sec-gpc”:
“1”,
“x-forwarded-for”:
“86.179.16.136”,
“x-forwarded-host”:
mango.monodon.eu”,
“x-forwarded-proto”:
“https”
},
“params”:
{
},
“query”:
{
},
“body”:
{
“nom”:
“John”,
“email”:
john@example.com”,
“fichier”:
“[object Object]”
}
}