I want to send a GET request on an anchor tag in pug. Is it possible without using form & submit button?
I did this code but it is not executing the server side route, it is directly displaying the page.
nav
ul.pagination
li.page-item
a.page-link Prev
each pageNumber in pages
li.page-item
a.page-link(href="/admin?page="+pageNumber)=pageNumber
li.page-item
a.page-link Next
I want to do something like this:
a.page-link(method="GET" action="/admin?page="+pageNumber)=pageNumber
>Solution :
Pug just generates HTML. So start by forgetting about Pug and focus on the HTML you want to generate.
Links make GET requests. They can’t do anything other than make a GET request. They don’t accept an method attribute.
The URL to make the GET request to is specified by the href attribute, not an action attribute.
a.page-link(href="/admin?page="+pageNumber)=pageNumber already makes the request you appear to want.
It must be executing some route on the server, otherwise the server wouldn’t respond with a page for the browser to render.