0

I have a html page (product page) which now I have to fill with content from a .json file (array with different products, accessible via id). In the url you should be able to set a GET parameter like this:

/product?product_id=14

I know that no more information will be passed in the url, so I don't need to use any regex.

Now I simply have no idea to get the content into my html file, all I know so far is (js file):

let h1 = document.querySelector('h1');
if (h1) {
  h1.textContent = '#1';
} else {
  console.log('#1: No content found!');
}

So now I need to know which id was passed via GET parameter and how to load the content from the .json database.

Thanks in advance

Estefunny
  • 43
  • 1
  • 10

1 Answers1

0

Here's an easy way to get the parameter from the URL: https://stackoverflow.com/a/20336097/7303349

And then getting the json database sounds like an entirely different step. Try to do less things at a time. Also, where does the .json database come from?

Simon Visser
  • 364
  • 3
  • 14
  • the only reason for the .json file is to store all products in an array, this file is given to build my html page on – Estefunny Jun 01 '17 at 13:33