Anyone good with typescript or have built an e-commerce website? Help please!
Im trying to make the user be able to navigate in and out of the different categories but I cant figure out how, The categories are fetched from a database and I have a navbar displaying the different categories but I cant figure out how to navigate in and out of them, would appreciate any help that can point me in the right direction. Here is my code down below. Thanks class Category { categoryId : number; category: string; constructor(categoryId: number, category: string) { this.categoryId = categoryId; this.category = category; } get() { return this.category; } createNavItem(){ return '<a class="navbar-item" categoryId="' + this.categoryId + '">' + this.category + '</a>'; } } fetch ('http://localhost:8888/ECshop/service/index.php?_action=CategoryGetList') .then(function(response) { return response.json(); }) .then(function(myJson) { console.log(myJson); //alert(myJson.description); //console.log(JSON.stringify(myJson)); }) .catch(function (error) { console.log(error.message); }); var Categories = Array<Category>(); function CategoryGetList() { fetch('service/index.php?_action=CategoryGetList') .then(function(response) { return response.json(); }) .then(function(data) { console.log(data); for (let i=1; i<data.length; i++){ Categories.push(new Category(data[i].category_id,data[i].category)); } }) .then(function() { var html:string = ""; for (let i = 0; i<Categories.length; i++) { html += Categories[i].createNavItem(); } let navBar = document.getElementById('nav-categories') as HTMLInputElement; navBar.innerHTML = html; }) .then (function(){ var classes = document.getElementsByClassName('navbar-item'); for (var i = 0; i < classes.length; ++i) {