![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/vreg/node_modules/smartystreets-javascript-sdk/examples/ |
const SmartyStreetsSDK = require("smartystreets-javascript-sdk"); const SmartyStreetsCore = SmartyStreetsSDK.core; const Lookup = SmartyStreetsSDK.internationalStreet.Lookup; // for Server-to-server requests, use this code: // let authId = process.env.SMARTY_AUTH_ID; // let authToken = process.env.SMARTY_AUTH_TOKEN; // const credentials = new SmartyStreetsCore.StaticCredentials(authId, authToken); // for client-side requests (browser/mobile), use this code: let key = process.env.SMARTY_WEBSITE_KEY; const credentials = new SmartyStreetsCore.SharedCredentials(key); // The appropriate license values to be used for your subscriptions // can be found on the Subscription page of the account dashboard. // https://www.smartystreets.com/docs/cloud/licensing let clientBuilder = new SmartyStreetsCore.ClientBuilder(credentials).withLicenses(["international-global-plus-cloud"]); let client = clientBuilder.buildInternationalStreetClient(); // Documentation for input fields can be found at: // https://smartystreets.com/docs/cloud/international-street-api#http-input-fields let lookup1 = new Lookup("CA", "262 Browndale Cr, Richmond Hill, ON"); let lookup2 = new Lookup(); lookup2.inputId = "ID-8675309"; lookup2.geocode = false; lookup2.organization = "John Doe"; lookup2.address1 = "Rua Padre Antonio D'Angelo 121"; lookup2.address2 = "Casa Verde"; lookup2.locality = "Sao Paulo"; lookup2.administrativeArea = "SP"; lookup2.country = "Brazil"; lookup2.postalCode = "02516-050"; client.send(lookup1) .then(displayResult) .catch(handleError); client.send(lookup2) .then(displayResult) .catch(handleError); function displayResult(result) { console.log(result.result[0].components); } function handleError(error) { console.log("ERROR:", error); }