Created
September 23, 2024 14:09
-
-
Save jackcoldrick90/d130d75c8821cb1baa97d3fbfe34fb7f 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
/* Example 2: Make a HTTP Request to Kickbox Email Verification API using NodeJS axios */ | |
//1. Import libraries, in this instance "axios" to make HTTP requests | |
const axios = require('axios'); | |
exports.main = async (event, callback) => { | |
//2. Store contact email in variable | |
var email = event.inputFields['email']; | |
//3. Configure and Make our HTTP request to Kickbox Email Verification API | |
axios.get("https://api.kickbox.com/v2/verify", { | |
"params": { | |
"email": email, // include contact email | |
"apikey": process.env.KICKBOX_ACCESS_TOKEN // include API key | |
} | |
}) | |
.then((response) => { // Run code when we get response | |
//4. Pass the data back to workflow using outputFields - make sure to also define data output types | |
callback({ | |
outputFields: { | |
"role": response.data.role, | |
"free": response.data.free, | |
"disposable": response.data.disposable, | |
"sendex": response.data.sendex, | |
"result": response.data.result, | |
"reason": response.data.reason | |
} | |
}) | |
}) | |
.catch((error) => { | |
console.log(error); // Output any errors | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment