Last active
June 14, 2023 13:57
-
-
Save jordanisip/5b3a93dde18c7e66d3b02ed4cb9ff77b to your computer and use it in GitHub Desktop.
Waypoint Axios example
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
const axios = require('axios'); | |
axios({ | |
method: 'post', | |
url: 'https://live.waypointapi.com/v1/email_messages', | |
headers: { | |
'Content-Type': 'application/json' | |
}, | |
auth: { | |
username: 'YOUR_API_KEY_USERNAME', | |
password: 'YOUR_API_KEY_PASSWORD' | |
}, | |
data: { | |
templateId: 'YOUR_TEMPLATE_ID', | |
to: 'YOUR_TEST_EMAIL_ADDRESS', | |
variables: { | |
reservationRequest: { | |
id: '2334234', | |
displayName: 'Jordan', | |
startDate: 'Aug 1', | |
endDate: 'Aug 29', | |
message: 'Any chance you have time to watch my dog, Odin, again?', | |
} | |
} | |
} | |
}) | |
.then(function (response) { | |
// handle success | |
console.log(`https://dashboard.usewaypoint.com/o/YOUR_PLATFORM_ID/events/${response.data.data.id}`); | |
}) | |
.catch(function (error) { | |
// handle error | |
console.log(error); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment