![]() 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.usExtract.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); let clientBuilder = new SmartyStreetsCore.ClientBuilder(credentials); // .withBaseUrl(""); let client = clientBuilder.buildUsExtractClient(); // Documentation for input fields can be found at: // https://smartystreets.com/docs/cloud/us-extract-api#http-request-input-fields let lookup = new Lookup("If you work at 1600 Pennsylvania Ave NW, Washington DC you're gonna have a hard time."); lookup.aggressive = true; lookup.addressesHaveLineBreaks = false; lookup.addressesPerLine = 1; client.send(lookup) .then(logResult) .catch(console.log); function logResult(response) { console.log(response.result); }