PercyODI / Stage2.PieAuction

0 stars 5 forks source link

What is the URLSearchParams object? #2

Open PercyODI opened 4 years ago

PercyODI commented 4 years ago

File: PieAuction.FrontEnd/pie_page/pie_page.js LineNumber: 5


In pie_page.js, line 5, there is a new URLSearchParams object with window.location.search as a parameter. What is this doing?

PercyODI commented 4 years ago

This page uses query string parameters to determine which pie to load. If you click on a pie from the table in the first page, you'll see that at the end of the address, there is something that looks like ?pieId=92f73054-babe-40a3-8133-4740a0bc368d. When URLSearchParams runs, it pulls that pie id, sets the value to a global variable called pieId.

That pie id is then used to call the API and get the details about that Pie.