You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im using this lib, and when searching using the async first takes some time to load since is pending the request finishes, any ideia how to improve this? since when i type bananas, some calls are made but because they are using aync even if the finnal call have results they dont get appended.
Also in some queries the endpoint returns an array with results, but the input dont show them on the list.
` var autoCompleteJS = new autoComplete({
selector: "#" + autoCompleteId,
placeHolder: "Search for Fruits...",
threshold: 4,
data: {
src: async (query) => {
if (query === "") {
return;
}
try {
// Fetch Data from external Source
const source = await fetch(`endpoint?search=${query}`);
// Data should be an array of `Objects` or `Strings`
const response = await source.json();
console.log(response)
return response.data;
} catch (error) { console.log(error)
return error;
}
},
// Data source 'Object' key to be searched
keys: ["value"],
},
resultsList: {
element: function element(list, data) {
if (!data.results.length) {
// Create "No Results" message element
var message = document.createElement("div");
// Add class to the created element
message.setAttribute("class", "no_result");
// Add message text content
message.innerHTML = "<span>Found No Results for \"" + data.query + "\"</span>";
// Append message element to the results list
list.prepend(message);
}
},
noResults: true
},
resultItem: {
highlight: true
},
events: {
input: {
selection: function selection(event) {
var selection = event.detail.selection.value;
autoCompleteJS.input.value = selection;
}
}
}
});
`
Any ideia if its possible to use ajax insted of async method and awaits
The text was updated successfully, but these errors were encountered:
Im using this lib, and when searching using the async first takes some time to load since is pending the request finishes, any ideia how to improve this? since when i type bananas, some calls are made but because they are using aync even if the finnal call have results they dont get appended.
Also in some queries the endpoint returns an array with results, but the input dont show them on the list.
0: {value: 'Rua Adelina Lessa dos Santos , 46100-970 Brumado\r\n', data: Array(2)} 1: {value: 'Rua Presidente Castelo Branco , 46100-970 Brumado\r\n', data: Array(2)} }
code im using
` var autoCompleteJS = new autoComplete({
selector: "#" + autoCompleteId,
placeHolder: "Search for Fruits...",
threshold: 4,
data: {
src: async (query) => {
if (query === "") {
return;
}
`
Any ideia if its possible to use ajax insted of async method and awaits
The text was updated successfully, but these errors were encountered: