Product listing

Let's now design the jQuery code needed to consume this endpoint so that we can show these records on a web page and list our products available to buy. This should look as follows:

function LoadProducts() {  // Load products' details.  $.ajax({    url: 'http://localhost:57571/api/Productsdetails',    type: "GET",    contentType: "application/json",    dataType: "json",    success: function (result) {      $.each(result, function (index, value) {        $('#tblProducts')        .append('<tr><td>' +        '<h3>' + value.name + '</h3>' +        '<p>' + value.description + '</p>' +        '<a target="_blank" href=' + value.url + '>Amazon Link</a>' +        '<input type="button" style="float:right;"         class="btn btn-success" value="Add To Cart" />' +        '</td></tr>');      });    }  });}
To get the code ...

Get Building RESTful Web Services with .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.