Last active
February 9, 2021 20:26
-
-
Save isaidspaghetti/cd9633bb18c48f66845b5059f2613c96 to your computer and use it in GitHub Desktop.
Index createHubspotContact
This file contains 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
//backend/routes/index.js:10 | |
async function createHubspotContact(firstName, lastName, email) { | |
let hubspotContact; | |
try { | |
hubspotContact = await axios.get(`https://api.hubapi.com/crm/v3/objects/contacts/${email}/?idProperty=email&hapikey=${hubspotKey}`); | |
} | |
catch { | |
hubspotContact = await axios.post(`https://api.hubapi.com/crm/v3/objects/contacts?hapikey=${hubspotKey}`, | |
{ | |
properties: { | |
'firstname': firstName, | |
'lastname': lastName, | |
'email': email, | |
} | |
} | |
); | |
} | |
return hubspotContact.data.id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment