smartystreets-javascript-sdk
Advanced tools
Comparing version 1.11.6 to 1.11.7
@@ -20,9 +20,4 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
let lookup = new Lookup("Ave", "CAN"); | ||
await handleRequest(lookup, "Simple Request"); | ||
client.send(lookup) | ||
.then(function (results) { | ||
logSuggestions(results, "Simple Lookup"); | ||
}) | ||
.catch(console.log); | ||
// *** Using Filter and Prefer *** | ||
@@ -36,6 +31,5 @@ lookup = new Lookup("Ave", "CAN"); | ||
client.send(lookup) | ||
.then(function(results) { logSuggestions(results, "Using Filter and Prefer")}) | ||
.catch(console.log); | ||
await handleRequest(lookup, "Using Filter and Prefer"); | ||
function logSuggestions(response, message) { | ||
@@ -45,2 +39,11 @@ console.log(message); | ||
console.log("*********************"); | ||
} | ||
async function handleRequest(lookup, lookupType) { | ||
try { | ||
const results = await client.send(lookup); | ||
logSuggestions(results, lookupType); | ||
} catch(err) { | ||
console.log(err) | ||
} | ||
} |
@@ -36,8 +36,4 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(lookup1) | ||
.then(displayResult) | ||
.catch(handleError); | ||
client.send(lookup2) | ||
.then(displayResult) | ||
.catch(handleError); | ||
await handleRequest(lookup1) | ||
await handleRequest(lookup2) | ||
@@ -50,2 +46,11 @@ function displayResult(result) { | ||
console.log("ERROR:", error); | ||
} | ||
async function handleRequest(lookup) { | ||
try { | ||
const result = await client.send(lookup); | ||
displayResult(result); | ||
} catch(err) { | ||
handleError(err); | ||
} | ||
} |
@@ -22,5 +22,3 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(lookup) | ||
.then(function(results) { logSuggestions(results, "Simple Lookup") }) | ||
.catch(console.log); | ||
await handleRequest(lookup, "Simple Lookup"); | ||
@@ -36,5 +34,3 @@ // *** Using Filter and Prefer *** | ||
client.send(lookup) | ||
.then(function(results) { logSuggestions(results, "Using Filter and Prefer") }) | ||
.catch(console.log); | ||
await handleRequest(lookup, "Using Filter and Prefer"); | ||
@@ -46,5 +42,3 @@ // *** Using 'selected' to Expand Secondaries *** | ||
client.send(lookup) | ||
.then(function(results) { logSuggestions(results, "Using 'selected' to Expand Secondaries") }) | ||
.catch(console.log); | ||
await handleRequest(lookup, "Using 'selected' to Expand Secondaries") | ||
@@ -57,2 +51,11 @@ // ************************************************ | ||
console.log("*********************"); | ||
} | ||
async function handleRequest(lookup, lookupType) { | ||
try { | ||
const results = await client.send(lookup); | ||
logSuggestions(results, lookupType); | ||
} catch(err) { | ||
console.log(err) | ||
} | ||
} |
@@ -26,8 +26,15 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(lookup) | ||
.then(logResult) | ||
.catch(console.log); | ||
await handleRequest(lookup); | ||
function logResult(response) { | ||
console.log(response.result); | ||
} | ||
async function handleRequest(lookup) { | ||
try { | ||
const response = await client.send(lookup); | ||
logResult(response); | ||
} catch(err) { | ||
console.log(err); | ||
} | ||
} |
@@ -23,5 +23,3 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(lookup1) | ||
.then(displayResult) | ||
.catch(handleError); | ||
await handleResponse(lookup1); | ||
@@ -35,1 +33,10 @@ function displayResult(result) { | ||
} | ||
async function handleResponse(lookup) { | ||
try { | ||
const result = await client.send(lookup); | ||
displayResult(result); | ||
} catch(err) { | ||
handleError(err); | ||
} | ||
} |
@@ -54,5 +54,3 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(batch) | ||
.then(handleSuccess) | ||
.catch(handleError); | ||
await handleResponse(batch); | ||
@@ -65,2 +63,11 @@ function handleSuccess(response) { | ||
console.log(response); | ||
} | ||
async function handleResponse(lookup) { | ||
try { | ||
const result = await client.send(lookup); | ||
handleSuccess(result); | ||
} catch(err) { | ||
handleError(err); | ||
} | ||
} |
@@ -40,5 +40,3 @@ const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); | ||
client.send(batch) | ||
.then(viewResults) | ||
.catch(console.log); | ||
await handleResponse(batch); | ||
@@ -50,2 +48,11 @@ function viewResults(response) { | ||
})); | ||
} | ||
async function handleResponse(lookup) { | ||
try { | ||
const result = await client.send(lookup); | ||
viewResults(result); | ||
} catch(err) { | ||
console.log(err); | ||
} | ||
} |
{ | ||
"name": "smartystreets-javascript-sdk", | ||
"version": "1.11.6", | ||
"version": "1.11.7", | ||
"description": "Quick and easy SmartyStreets address validation.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
166986
3821