This can be used with any backend api or can be used in server side rendering after some little tweaks
-
In index.html
<form action="/data" method="get" autocomplete="off" class="search-form">
change the action attribute with your API endpoint -
In autoSugest.js
async function searchBook(searchText) { let url = "/data.json";
change the url with your API endpoint -
In autoSugest.js
function showSuggestion(arr) { //other codes b.addEventListener("click", function (e) { ... form.action = "/data/" + id; ... } //other codes }
-
change form.action with your API endpoint