Good afternoon everyone!
I am trying to implement a GET call with Jquery where I iterate a list and I have it as follows.
<script>
$(document).ready(function(){
$.getJSON("https://jsonplaceholder.typicode.com/posts", function(result){
$.each(result, function(i, field){
console.log("UserId: " + field.userId);
console.log("Field: " +field.id);
console.log("Title: " + field.title);
});
});
$.ajax({
type: 'GET',
url: 'https://jsonplaceholder.typicode.com/posts',
dataType: 'json',
success: function(resp){
console.log("OK");
console.log(resp);
}
});
});
</script>
Well, I would like to know which is the most efficient way to iterate the list since on the part of Back which is the domain I would return an empty list if there is no data or just the list if there is information (I do not speak of the page)
Although from what I have seen the response of Back, if the list is empty it should be a 200 since the list is returned but empty.
How could you control the empty response from FrontEnd?