Setting-Up Node.js SDK

The Node.js SDK is available for installation via npm repository: https://www.npmjs.com/package/preciselyapis-client

Create a folder for your Node js project. Run following command to create an empty project:

npm init

To install Node.js SDK client to your local project, simply execute:

npm install preciselyapis-client

To deploy it globally, simply execute:

npm install -g preciselyapis-client 

Now, you must set-up API Key & Secret in the Node.js SDK. Obtain your API Key and Secret from your developer account Refer 'Obtaining Credentials (API Key and Secret)'.

Create an empty JavaScript file and paste the following code snippet:

//We are getting refrence to the installed preciselyapis-client package
const PreciselyAPINodeJS = require('preciselyapis-client');

try     {
    // Configure OAuth2 API_KEY and SECRET for authorization
    const oAuth = new PreciselyAPINodeJS.OAuth();
    oAuth.oAuthApiKey="API_KEY";
    oAuth.oAuthSecret="SECRET";


    oAuth.getOAuthCredentials().then((data) => {


        var _911PSAPServiceApi = new PreciselyAPINodeJS._911PSAPServiceApi(data.body);
		
        _911PSAPServiceApi.getAHJPlusPSAPByAddress("950 Josephine Street Denver CO 80204").then((response) => {
            console.log("Result " + JSON.stringify(response.body));
        }).catch((response) => {
            console.log("Error " + JSON.stringify(response.body));
        });
 }).catch((error) => {
        console.log("Error" + JSON.stringify(error))
    });
}
catch (error1) {
    console.log("Exception raised"+ error1);
}

In the above code snippet, put your API key and Secret from your developer account:

oAuth.oAuthApiKey="API_KEY";
oAuth.oAuthSecret="SECRET";