From the course: Building Full-Stack Applications with HTMX
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution #2: Searching articles - HTMX Tutorial
From the course: Building Full-Stack Applications with HTMX
Solution #2: Searching articles
- [Instructor] Now that you have implemented the instructions for the second task for searching articles, now let's do it together. Don't worry if your implementation probably isn't working at the moment. That's what the solution videos are for. So let's start from the first step. Step one says we should refactor the articles endpoint to take in a search parameter. So let us include that to the list of variables we are getting from our request. I'll be giving this search query variable, the letter Q, just for simplicity. So let's bring that in and go to step two. Step two says, we should use this search parameter to search both the title and content fields in our database of articles. So let's implement that in our endpoint. Going to write a code to query the title and make it a case insensitive search. We can now slot this query into our find function. This way we can return the list of articles filtered by the search term. Perfect. Now in step three, let's go step three. In step…