I just started full stack development and I'm currently working with node, js and django. On my home page I have 2 products(express) but when I click on an individual product I get redirected to a blank page and I'm not sure why
Here is my code for individual product
window.onload = ()=>{
let params = window.location.search;
let urlParams = new URLSearchParams(params);
let productID = urlParams.get("id");
// http://127.0.0.1:8000/api/products/id
if(productID != null && typeof(productID)!= 'undefined'){
fetch('http://127.0.0.1:8000/api/products/'+productID)
.then(resp => resp.json())
.then(data => {
console.log(data);
if('detail' in data){
// display some generic product not found error
}
else{
let name = data['name'];
let desc = data['description'];
let price = data['price'];
let image= data['image'];
// display the product data
}
});
}
}