-1

我想将 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);
    
  });
4

2 回答 2

0

您可以将 API 密钥作为 URL 参数传递,如下所示:

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

于 2021-06-17T05:54:27.003 回答
0

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

var pivot = new WebDataRocks({
    container: "#wdr-component",
    toolbar: true,
    report: {
        dataSource: {
            data: yourData // your variable containing the data
        }
    }
});
于 2021-06-22T09:47:39.680 回答