Reputation: 771
I am trying to load a dataset from the URL "https://data.raleighnc.gov/resource/5ccj-g2ps.json" but it requires an API key. I have had no luck with D3 or Jquery.
How would I go about doing this so that I can load the dataset in Json format?
I have the following:
$.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);
});
It says I have a misplaced "{" but I don't see where.
Upvotes: 0
Views: 230
Reputation: 3227
There are a lot of mistakes in your code...
$.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
}
});
Should be working.
Upvotes: 1