I've created a Pagination and i'm facing some issues, the goal is to when the URL is '/platform' then use the DOM to update the pagination. I'm using Express to pass in the URL path (req.url).
var mainPath = '<%=url[1]%>'
var pathURL = '<%=url[2]%>'
let link1 = document.getElementById('link1')
let link2 = document.getElementById('link2')
let link3 = document.getElementById('link3')
if(mainPath == 'page') {
let pastPage = pathURL - 1;
let nextPage = pathURL + 1;
linkk1.innerHTML = '<a class="page-link" href="/page/'+ pastPage +'">'+ pastPage +'</a>'
linkk2.innerHTML = '<a class="page-link" href="/page/'+ pathURL +'">'+ pathURL +'</a>'
linkk3.innerHTML = '<a class="page-link" href="/page/'+ nextPage +'">'+ nextPage +'</a>'
} else if(mainPath == 'platform') {
let pastPage = pathURL - 1;
let nextPage = pastPage + 2;
link1.innerHTML = '<a class="page-link" href="/platform/'+pathURL+'/'+pastPage+'">'+pastPage+'</a>'
linkk2.innerHTML = '<li id="page-2" class="page-item"><a class="page-link" href="/platform/'+pathURL+'/'+pathNumber+'">'+pathURL+'</a>'
linkk3.innerHTML = '<a class="page-link" href="/platform/'+pathURL+'/'+pathNum+'">'+nextPage+'</a>'
}
The issue is, when the URL is 'platform', it doesn't update the href to like below
href='/platform'