我想将 API 密钥附加到我的 URL 以授予对数据库的访问权限,问题是将其附加到文件名

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

我想将 API 密钥附加到我的 URL 以授予对数据库的访问权限,问题是将其附加到文件名

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

此代码适用于控制台

  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);
    
  });

您可以像这样将 API-键作为 URL 参数传递:

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

如果需要传递请求头,最好通过与WebDataRocks分开的请求来获取数据。这样它就可以包含所有需要的信息。之后,可以通过以下方式将数据从网页馈送到WebDataRocks:

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