When making a POST request to submit data using an endpoint, such as http://localhost:3000/entry, with keys like fname, lname, and age, the submission is successful. However, I am facing an issue where upon form submission, it redirects to the endpoint itself instead of staying on the current page. My project is built using VueJS.
In addition, there is another endpoint available at http://localhost:3000/entries (GET) which returns existing entries in JSON format, for example:
[
{
"_id": "5b48a137c3b2a3454b853a3c",
"fname": "John",
"lname": "Jose",
"age": "28",
"__v": 0
},
{
"_id": "5b506cc7d9105012f59c87e6",
"fname": "Alex",
"lname": "Cruz",
"age": "27",
"__v": 0
}
]
Instead of redirecting when submitting the form, my goal is to update the HTML table with the latest data from the API endpoint http://localhost:3000/entries.
In the provided code snippets, index.html mentions the necessary scripts and styles for vue.js implementation, along with form elements and a table structure for displaying data. The script.js file includes Vue instance creation with data properties and methods for form validation. Lastly, an updated version of the table structure is given to handle dynamic rendering of entry details fetched from the API endpoint.