Currently, I am in the process of developing an application using Javascript along with express, express-handlebars, and MySQL.
One of my main tasks is to establish a route that follows the pattern '/viewowner/:ID/scoreboards/:year' where ID signifies a unique owner ID, and year represents a specific year's data.
The SQL query I have set up relies on extracting both the ID and the year.
Presently, the structure of my anchor tag is as follows:
{{#each output}}
<li class="list-inline-item"><a href="/viewowner//scoreboards/{{this}}">{{this}}</a></li>
{{/each}}
This code snippet loops through the output array and displays a list of items from the output. While the link includes the year, I am facing the challenge of integrating the ID into the link. The ID value originates from a separate array (s1), which I manage to isolate using JavaScript techniques like .push() to append it to the output array.
An illustrative instance showcases an updated output array resembling [2015, 2016, 2017, 2018, 2019, 2020, 3].
In an attempt to address this concern, I introduced a new variable:
var l = output.length
var yearlinks ={
'years': output,
'id': output.splice(l-1,1)
}
This approach resulted in two distinct arrays within yearlinks: yearlinks.years containing all years, and yearlinks.id encompassing only the ID number.
Despite trying to iterate through the elements of yearlinks, I encountered difficulties making it function as intended.
{{#each yearlinks}}
<li class="list-inline-item"><a href="/viewowner/{{id}}/scoreboards/{{#each years}}{{this}}{{/each}}">{{#each years}}{{this}}{{/each}}</a></li>
{{/each}}
If anyone has insights on how to overcome this issue or can guide me towards relevant resources, your assistance would be greatly appreciated. Thank you!