加载D3 Url与API密钥



我试图从URL "https://data.raleighnc.gov/resource/5ccj-g2ps.json"加载数据集,但它需要API密钥。我在使用D3或Jquery时运气不佳。

我该怎么做,这样我就可以在Json格式加载数据集?

我有以下内容:

$.ajax({
url: "https://data.raleighnc.gov/resource/xce4-kemu.json",
type: "GET",
data: {
  "$limit" : 5000,
  "$$app_token" : "YOURAPPTOKENHERE"
}
}).done(data) {
alert("Retrieved " + data.length + " records from the dataset!");
console.log(data);
});

它说我有一个错误的"{",但我不知道在哪里。

你的代码中有很多错误…

$.ajax({
    url: "https://data.raleighnc.gov/resource/xce4-kemu.json", // didn't you want to get another URL??!?
    type: "GET",
    dataType: "json",
    data: {
      "$limit" : 5000, // Does the API require the dollar signs? Looks weird.
      "$$app_token" : "YOURAPPTOKENHERE" // Did you actually replace with your API key?
    },
    success: (data) => {
        alert("Retrieved " + data.length + " records from the dataset!");
        console.log(data);
    },
    error: (xhr, textStatus, errorThrown) => {
        // error
    }
});

最新更新