-1

I want to attach an API key to my URL to give access to the database, the problem is attaching it to the filename

var pivot = new WebDataRocks({
    container: "#wdr-component",
    toolbar: true,
    report: {
        dataSource: {
            filename: "https://testing-195b.restdb.io/rest/customerdata"
        }
    }
});

this code worked for the console

  var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://testing-195b.restdb.io/rest/customerdata",
    "method": "GET",
    "headers": {
      "content-type": "application/json",
      "x-apikey": "60c8b39ee2c96c46a2463581",
      "cache-control": "no-cache"
      
    }
  }
  
  $.ajax(settings).done(function (response) {
    console.log(response);
    
  });
KargWare
  • 1,746
  • 3
  • 22
  • 35
  • 1
    What is the problem? – Spectric Jun 16 '21 at 15:18
  • I am working with a database called restdb.io, a Web page API key (CORS) was generated ,which I need if am to gain access into my database, the problem here is I am using a web reporting tool which have there own syntax, I need to find way to attach the API key or bypass an error "No 'Access-Control-Allow-Origin" – Demilade Kusa Jun 16 '21 at 15:42

2 Answers2

0

you can pass the API-key as an URL parameter like this:

"https://testing-195b.restdb.io/rest/customerdata?apikey=XXXXXXXX"

  • thanks for the contribution, but unfortunately this method still doesn't work, the error :"It seems that this file doesn't exist or 'Access-Control-Allow-Origin' header is absent in the resource requested", still appears. – Demilade Kusa Jun 17 '21 at 10:09
  • Have you checked the Cors settings for this API-key? Domain and path must match, but for test you can use /** for path and * for domain – Jon Erik Solheim Jun 18 '21 at 05:48
0

In case it is needed to pass the request headers, it's better to get the data by making a request separately from WebDataRocks. This way it can contain all the needed information. After that, the data can be fed from the webpage to WebDataRocks the following way:

var pivot = new WebDataRocks({
    container: "#wdr-component",
    toolbar: true,
    report: {
        dataSource: {
            data: yourData // your variable containing the data
        }
    }
});
Tanya
  • 76
  • 4