How to find a file.csv/.json inside of a folder (by code) and use it as datasource


I have a folder named “static” which contains another folder called “data” where I uploaded several .csv and .json files, and I want to know how to access those files in order to use them as data source for my webdatarocks table.
I tried with: ./static/data/test.csv
and none of those seem to be working, because it throws an error saying:
Unable to open file static/data/test.csv

It seems that this file doesn’t exist or ‘Access-Control-Allow-Origin’ header is absent in the resource requested.

let pivote = new WebDataRocks({
        container: "#wdr-component",
        toolbar: true,
        report: {
            dataSource: {
                filename:  //here
                fieldSeparator: ","
slice: objReporte.slice,
            grid: objReporte.grid

1 answer

WebDataRocks Team WebDataRocks September 3, 2019

Thank you for writing to us.
Please open dev tools console area (F12 -> console) and check what path WebDataRocks uses to access the file. With such information, you can adjust the input path.
If you are using a local server make sure that you can access the file using the full path. In case the path is correct but you are still not able to access the file please configure CORS on your server:
WebDataRocks Team