Skip to content

Instantly share code, notes, and snippets.

@hishaamn
Created April 17, 2024 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hishaamn/b40b4d2bb9831ed8d6303591b6658d7c to your computer and use it in GitHub Desktop.
Save hishaamn/b40b4d2bb9831ed8d6303591b6658d7c to your computer and use it in GitHub Desktop.
// Omit above code for brevity
const handleSubmit = async (e) => {
e.preventDefault();
setButtonLoading(true);
var dict = [];
dict.push({
key: "Name",
value: name
});
dict.push({
key: "Email",
value: email
});
dict.push({
key: "Phone",
value: phone
});
dict.push({
key: "Message",
value: message
});
const postData = {
contactIdentifier: 'receiver@email.com',
formData: dict,
emailCampaignId: 'Your Email Campaign Item ID',
source: "ListManager"
};
const response = await fetch('https://yourapi.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
},
body: JSON.stringify(postData),
});
if (response.ok) {
navigate('/success');
setButtonLoading(false);
} else {
alert('Failed to submit form');
}
};
// Omit below code for brevity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment