How can i use api for data in report property

40 Views Asked by At
    const pivot = new WebDataRocks({
          container: "#wdr-component",
          toolbar: true,
          height: 490,
          report: {
            dataSource: 
            {
              filename: "https://cdn.webdatarocks.com/data/data.csv"
            },
            options: {
              grid: {
                title: "REPORT",
                showHeaders: false
              }
            }
          }
        });

If i try to hit an api inside the filename or data its not working but if i try to call an api in report its working

For Example:

dataSource: 
        {
          data: "http://localhost:8082/getUser"
        }
(or)
dataSource: 
        {
          filename: "http://localhost:8082/getUser"
        }

instead of csv i want to use api for getting data

1

There are 1 best solutions below

0
nadia khodakivska On

When using the WebDataRocks dataSource object, you have two options for defining your data - either use the filename property to specify the URL of a JSON or CSV file(also can be the URL to the server-side script generating the data) or use the data property to specify JSON data directly. Please ensure that your data is in the correct format, which is an array of objects, with each object containing an unordered collection of key/value pairs.

It is important to note that your API endpoint must return the data in the correct format and that it should be available to your application. If you face any issues, it may be due to CORS or other network-related problems.