$(document).ready(async function() { await loadmovie(); }); async function loadmovie() { await $.get("/api/movies", rendermovie); } function rendermovie(movies) { movies.sort(function(a, b) { return a.title.localeCompare(b.title); }); // movies.sort(function(a, b) { // aJ = Date.parse(a.released); // bJ = Date.parse(b.released); // return bJ - aJ; // }); movies.forEach(function(movie) { var row = document.createElement("div"); row.className = "col"; row.innerHTML = "
"+ "" + "
" + "
"+ movie.title + "
" + "

"+ movie.released + "

" + // "

"+ movie.genre + "

" + "
" + "
"; $("#movie_tbody").append(row); }); }