We have prepared a sample Node.js server that implements the custom data source API. It is available on our GitHub.
To run our sample Node.js server, follow the steps below.
Step 1.1. To get our sample project, download it as ZIP or clone it with the following command:
git clone https://github.com/flexmonster/api-data-source
Step 1.2. The sample Node.js server is available in the server-nodejs/
folder. Navigate to this folder:
cd api-data-source/server-nodejs
Install the npm dependencies described in the package.json
file:
npm install
To start the server, run the following commands in a console:
npm start
All requests from Flexmonster Pivot are handled by the http://localhost:3400/api/cube
endpoint.
Raw data is stored in JSON format in the server-nodejs/data/
folder.
On the client side (see /client/index.html
), the report should be configured as follows:
new Flexmonster({ container: "pivotContainer", componentFolder: "node_modules/flexmonster/", report: { dataSource: { type: "api", url: "http://localhost:3400/api/cube", index: "fm-product-sales" } } });
The dataSource.index
property matches the name of the JSON file from the server-nodejs/data/
folder.
To see Flexmonster with the data from the sample Node.js server, open the client/index.html
file in a browser.
You may be interested in the following articles: