Я новичок в JS и мне нужна помощь для массива ответов:
В следующем URL-адресе 5 электронных писем.Как правильно получить все письма от 5 объектов от https://jsonplaceholder.typicode.com/comments?
В моем коде я получаю только первое письмо:
var root = "https://jsonplaceholder.typicode.com/comments";
$.ajax (root, {
dataType: "json",
method: 'GET',
success: function(response){
var userId = response[0].postId;
var title = response[0].email;
// var title = $(response).filter('email');
var $info = $("<p></p>");
$info.text("Post id is: " + userId + " email is " + title);
$("div.main").append($info);
console.log(response);
},
error: function(request,errorType, errorMsg){
alert("Ajax Fehlfunktion:" + errorMsg);
},
data: {"postId": 1},
});