Skip to content

Commit

Permalink
Add search for user #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 20, 2024
1 parent 824a656 commit f1e584f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,27 @@
function performSearch() {
const query = document.getElementById('searchUser').value;
const userInstance = '{{ user.url }}';

// Show the spinner before starting the fetch operation
spinner.style.display = 'block';

fetch(`${baseUrl}/search?query=${encodeURIComponent(query)}&instance=${encodeURIComponent(userInstance)}`)
.then(response => {
if (!response.ok) {
throw new Error('Failed to fetch data from the server');
}

return response.json();
})
.then(data => {
displayResults(data);
console.log(data);
})
.catch(error => console.error('Error:', error));
.catch(error => console.error('Error:', error))
.finally(() => {
// Hide the spinner in case of an error
spinner.style.display = 'none';
});
}

function displayResults(results) {
Expand Down

0 comments on commit f1e584f

Please sign in to comment.