The similar questions didnt work for me. I have a AJAX GET request. When I show the entire json in the console log it works, but I cant select a single object from it.
My JS
$.ajax({
type: "GET",
url: "http://localhost:8092/api/getdata",
dataType: "json",
success: function (data) {
console.log(data["date"]);
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
This code returns undefined but if I only use console.log(data) it shows everything. Not sure what to do from here.
This is the output when I use console.log(data)
{
"date": "04-06-2020",
"id": 4
}
SS when I use console.log(data)
SS when I use console.log(data["id"])


data?dataor not? That JSON, if it is a string, then it is missing commas andid::4should beid:4. This{"date": "04-06-2020", "id": 4}is correct. Without the comma, it is not.Unexpected token oif there is nooin your json[object Object]which has anoin position 1.