Created
September 22, 2021 14:08
-
-
Save SidneyAllen/41316eb63e9e4906f617bbf0df5ff639 to your computer and use it in GitHub Desktop.
bulk-us-verification
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
// Call the Lob API to verify the passed addresses in bulk | |
Lob.bulkUSVerifications.verify({ | |
addresses: addresses | |
}, function (err, res) { | |
console.log(err, res); | |
if (!err) { | |
let i = 0; | |
let invalid = 0; | |
// Add the status and full_address attributes to the results | |
const lob_addresses = results.rows.map((e) => { | |
const response_addr = res.addresses[i]; | |
/* switch statement */ | |
// Add the deliverability status | |
e["status"] = response_addr.deliverability; | |
/* Use the primary_line, secondary_line and last_line of the returned Lob address to display the address to the user */ | |
e["full_address"] = `${response_addr.primary_line} ${response_addr.secondary_line} ${response_addr.last_line}`; | |
i++; | |
return e; | |
}) | |
/* Return the response that contains the HTML file with the scanned addresses and the valid and invalid counts */ | |
response.render(path.join(__dirname, '/public', 'main.html'), { addresses: lob_addresses, scanned: res.addresses.length, valid: res.addresses.length - invalid, invalid: invalid }); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment