I’ve seen a lot of methods on rendering a webpage based on API’s response. But, it is generally immediately.
Go to website -> data fetched -> render on page.
But, I have a different need.
Go to website -> press a button -> fetch data -> render on page.
The press a button part is important. Because the data being fetched is determined by user input.
This is the page the user sees when they enter. Data is fetched after they press “Submit.”
From what I’ve read there are three options
- Use a template.
- Send data to a different endpoint and have the HTML page call that different endpoint.
- Have JS embedded using
<script></script>
in the HTML itself that will override what data is send when “Submit” is pressed and then handle the response.
I’m just wondering what my options are aside from the three that I’ve managed to find. FYI I’m using Express so if you would like to provide code examples I’d prefer code that would accommodate Express.