diff --git a/frontend/src/assets/js/app.js b/frontend/src/assets/js/app.js
index fc383b2..83dd057 100644
--- a/frontend/src/assets/js/app.js
+++ b/frontend/src/assets/js/app.js
@@ -1,9 +1,32 @@
const apiUrl = 'http://localhost:8001';
+function createTable(selector, items) {
+ const $table = $("
");
+ const $headerRow = $("
");
+
+ $.each(Object.keys(items[0]), function(i, key) {
+ const $th = $(" | ").text(key)
+ $headerRow.append($th);
+ });
+ $table.append($headerRow);
+
+ $.each(items, function (i, item) {
+ const $tr = $("
");
+ $.each(item, function(key, value) {
+ const $td = $(" | ").text(value);
+ $tr.append($td);
+ });
+ $table.append($tr);
+ });
+
+ console.log($table);
+
+ $(selector).append($table);
+}
function getCatalog() {
$.getJSON(apiUrl + "/catalog", function (resp) {
- console.log(resp)
- })
+ createTable('.posts', resp);
+ });
}
$( document ).ready(function() {
getCatalog();