🍉 Meet Flexmonster Pivot Table & Charts 2.9.Check out all the hot features!
Get Free Trial

How to fix the url for custom data source without end point

Answered
Brad Huang asked on December 31, 2020

If I assign an url custom data source like below. Is it possible when calling field/members/select
but without attach endpoint to url
e.g., http://localhost:3400/api/cube for field but not http://localhost:3400/api/cube/field
e.g., http://localhost:3400/api/cube for select but not http://localhost:3400/api/cube/select

var pivot = new Flexmonster({
container: "pivotContainer",
report: {
dataSource: {
    type: "api",
        url: "http://localhost:3400/api/cube",
        index: "data-set-123"
    }

}
});


7 answers

Public
Vera Didenko Vera Didenko Flexmonster December 31, 2020

Hello,
 
Thank you for writing to us. 
 
Yes, it is possible to have a single endpoint for all custom data source API requests.
This can be configured by specifying isSingleEndpointApi: true in the /handshake response.
For example, here is a code snippet using Node.js:

cube.post("/handshake", async (req, res) => {
try {
res.json({ version: API_VERSION, isSingleEndpointApi: true });
} catch (err) {
handleError(err, res);
}
});

As a result, Flexmonster will send all requests (/fields, /members, /select) to one endpoint that is specified in dataSource.url (in your case, to http://localhost:3400/api/cube).
 
Please let us know if this works.
Looking forward to your response.
 
Kind regards, 
Vera

Public
Brad Huang January 6, 2021

It’s not what I expected. Because I don’t want handshake with the end point”http://localhost:3400/api/cube/handshake” too.
It will be better for me if we can specify this from js directly.
EX:

new Flexmonster({
container: "pivot-container",
isSingleEndpointApi: true,
report: {
dataSource: {
type: "api",
url: "http://localhost:3400/api/cube",
index: "ABC"
}
}
});
Public
Vera Didenko Vera Didenko Flexmonster January 6, 2021

Hello, 
 
Thank you for your reply.
 
Regarding the idea to specify that a single endpoint is used as a configuration option (from JS directly):
Thank you for sharing your thoughts with us. Our team agrees that supporting such an approach would be a convenient feature to have.
Our team will look into this in more detail, and we will provide you with the results with the ETA 25th of January. 
 
Please let us know if this would work for you.
 
Kind regards,
Vera

Public
Brad Huang January 7, 2021

It will be great if you can add this feature, I would try this new feature after it finished.
Kind regards
Brad

Public
Vera Didenko Vera Didenko Flexmonster January 11, 2021

Hello, Brad,
 
Thank you for your response. 
 
We are happy to inform you that our team managed to provide the solution earlier than the given ETA.
Now a new singleEndpoint property is available in the Data Source Object. If set to true, all custom data source API requests will be sent to a single endpoint specified in dataSource.url.
Here is an example of singleEndpoint usage: 

dataSource:{
type:"api",
url:"http://localhost:3400/api/cube", <- All API requests will be sent to this endpoint
index:"fm-product-sales",
singleEndpoint: true
}

This is available in the latest minor release of Flexmonster: https://www.flexmonster.com/release-notes/.
You are welcome to update the component. Here is our updating to the latest version tutorial for guidance.
 
Please let us know if this works fine for you.
We would be grateful for your feedback.
 
Kind regards, 
Vera

Public
Vera Didenko Vera Didenko Flexmonster January 20, 2021

Hello, Brad,
 
Our team is wondering if you’ve found the latest feature helpful. 
Does the dataSource.singleEndpoint property work fine for you?
 
Please let us know if everything works.
Looking forward to your feedback.
 
Kind regards, 
Vera

Public
Brad Huang January 25, 2021

The new feature works fine for us. Thanks for your rapidly response.

Please login or Register to Submit Answer