Configuring the "conf" object

We need to set up the JavaScript file so that it can communicate with the LRS. This is managed using the "conf" JSON object. The conf object contains "endpoint" and "auth" properties. Therefore, add the following line of code right above where we define the "statement" variable:

{% c-block language="js" %}
const conf = {
 "endpoint": ,
 "auth":
};
{% c-block-end %}

If you're using the Veracity Learning LRS, then you can select the small downward facing arrow beneath your LRS's name to view the LRS endpoint.

Select dropdown arrow beneath LRS title

After selecting the dropdown arrow, you should see your endpoint URL.

Copy and paste LRS endpoint from beneath the LRS title

If you're using a different LRS, then look at their documentation to access the LRS endpoint.

Enter your endpoint within quotation marks as the value for the "endpoint" property. Make sure that there is a final forward slash after your URL.

You also need to set up the "auth" value so that it's ready to take the API Key username and password. Update your "conf" variable so that it looks like this:

{% c-block language="js" %}
const conf = {
 "endpoint": "https://my-test-lrs.lrs.io/xapi/",
 "auth": "Basic " + toBase64("Username:Password")
};
{% c-block-end %}

Important note: Ensure that there is a space between Basic and the quotation mark: "Basic ", not "Basic".

Now look at your API Key information in the Veracity LRS window that we left open earlier. Copy and paste the string in the "Username" field to the Username placeholder in our code, and do the same with the password and the Password placeholder.

The quotation mark before the username and the quotation mark after the password should remain.

If you're using a different LRS, the Username may be referred to as "API Key" and the password may be referred to as "API secret."

Finally, we need to tell the LRS that we've updated the configuration. We can do this by using the following line of code immediately after defining the "conf" object:

{% c-block language="js" %}
ADL.XAPIWrapper.changeConfig(conf);
{% c-block-end %}

All together, your code should look something like this:

{% c-block language="js" %}
function send_statement(verb, verbId, object, objectId) {
 const player = GetPlayer();
 const uNamejs = player.GetVar("uName");
 const uEmailjs = player.GetVar("uEmail");
 const conf = {
   "endpoint": "https://my-test-lrs.lrs.io/xapi/",
   "auth": "Basic " + toBase64("oiejfow:neionhwm")
 };
 ADL.XAPIWrapper.changeConfig(conf);
 const statement = {
   "actor": {
     "name": uNamejs,
     "mbox": "mailto:" + uEmailjs
   },
   "verb": {
     "id": verbId,
     "display": { "en-US": verb }
   },
   "object": {
     "id": objectId,
     "definition": {
       "name": { "en-US": object }
     }
   }
 };
 const result = ADL.XAPIWrapper.sendStatement(statement);
}
{% c-block-end %}