Live Search

"The live site search relies on the default WordPress REST API to deliver results, complete with an indication of post..."

The live site search relies on the default WordPress REST API to deliver results, complete with an indication of post type, and a flex layout for mobile screens.

The AJAX request is an async fetch() which resolves with Promise.all() to allow the easy destructuring of data for the DOM:

 const [postResponse, pageResponse] = await Promise.all([
          fetch("/wp-json/wp/v2/posts?search=" + searchQuery),
          fetch("/wp-json/wp/v2/pages?search=" + searchQuery),
        ]

The search function is wrapped in a timeout that behaves as a debouncer, to mitigate server load.