Hi everyone, I am trying to send data from Klavio form to SMSBump with JavaScript but nothing works.
It’s my JS:
window.addEventListener("klaviyoForms", function(e) {
if (e.detail.type == 'submit') {
var phone = e.detail.metaData.$phone_number;
if (phone !== '' && phone !== undefined) {
fetch('https://api.smsbump.com/v2/formsPublic/subscribe', {
method: 'POST',
body: JSON.stringify({
'form_id': 33330,
'phone': e.detail.metaData.$phone_number,
'country': 'US',
'email': e.detail.metaData.$email,
'source': e.detail.metaData.$source
}),
headers: {
'Content-Type' : 'application/json',
'x-smsbump-platform': 'shopify',
}
})
.then(response => {
console.log(response);
response.json();
});
} else {
console.log('Phone is empty');
}
}
});
In the console->network->subscribe(name resourse)->preview, I get:
message: "You need to fill in one of the fields."
What could be the reason?