Created
April 17, 2024 12:36
-
-
Save hishaamn/b40b4d2bb9831ed8d6303591b6658d7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: '[email protected]', | |
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