I’m attempting to use the code below and want to use the “FormData();” object to pass my dataset values (includes files and images) to my product (which is outside of Wix). However, I am getting errors when using this and well as with the standard “Buffer.from”.
Does any one have the optimal way to handle this within Wix?
import {getJSON} from ‘wix-fetch’;
import wixData from ‘wix-data’;
wixData.get(‘OnboardingDataset’, ‘item-key’)
.then(customer => {
const formData = new FormData();
formData.append(“Industry”, customer[‘Industry’]);
formData.append(“Users”, customer[‘Users’]);
formData.append(“Integration”, customer[‘Integration’]);
formData.append(“Template PDF”, customer[‘Template PDF’]);
formData.append(“Logo”, customer[‘Logo’]);
formData.append(“Email”, , customer[‘Email’]);
formData.append(“BusinessName”, customer[‘Business Name’]);
formData.append(“Business Address”, customer[‘Business Address’]);
formData.append(“Business City”, customer[‘Business City’]);
formData.append(“Business State”, customer[‘Business State’]);
formData.append(“Business Zip”, customer[‘Business Email’]);
formData.append(“Business Phone”, customer[‘Business Phone’]);
formData.append(“Template Name”, customer[‘Template Name’]);
return getJson('https://selfservicedev.expedata.net/qawebapi/onboarding/v1/init', {
method: 'POST',
headers: {
Authorization: 'Basic ' + Buffer.from(customer['Email'] + ":" + customer['Password']).toString('base64'),
},
body: formData
});
})
.then(result => {
const templatesUrl = result.templatesUrl;
const newTemplateDesignerUrl = result.newTemplateDesignerUrl;
// Do something with the urls.
})
.catch(err => {
// Handle the error
});