Tutorial #005: Connecting to Bloomreach XM with XIN Mods using NodeJS

In this Bloomreach XM with XIN Mods tutorial, we're going to talk about how to connect your NodeJS projects to a XIN Mods enabled Bloomreach instance!

Please find the contents of the files we edited in the tutorial below.

 

package.json

									{
									  "name": "recipe-tests",
									  "version": "1.0.0",
									  "description": "",
									  "main": "index.js",
									  "scripts": {
									    "test": "echo \"Error: no test specified\" && exit 1"
									  },
									  "author": "Marnix",
									  "license": "ISC",
									  "dependencies": {
									    "mocha": "^10.0.0",
									    "xinmods": "^1.6.11"
									  },
									  "devDependencies": {
									    "core-js": "^3.22.4"
									  }
									}
									

 

connectAndRead.js

 

									const xinmods = require("xinmods");
									
									describe("A simple connecting test to Bloomreach XM", () => {
									
									    it("should connect and get a document", async () => {
									
									        const conn = xinmods.connectTo("http://localhost:8080", "admin", "admin");
									        const doc = await conn.getDocumentByPath("/content/documents/recipes/cupcakes-recipe");
									
									        console.log(JSON.stringify(doc, null, 4));
									
									    });
									
									});
									

Also Read