Using the blog API
In this article, we will see how to retrieve blog posts using our blog REST API and use a search bar to find them.
Let's see the result first 😎
Let's go, first of all, it is necessary to have a:
- Source code element of type jQuery.
- Cloud backend inputs element of type 'input text' to which we will give a 'search-input' name as in the image below.
See the Pen APIBLOG/SearchBar by David (@DavidAppdrag) on CodePen.
Let's explain the essential elements of this code:
- We call the blog API 'https://api.appdrag.com/api.aspx' by passing it several data including the text (txt in the code) that the user types in the search bar.
- For each result we use a factory to generate each article (createLine (container, article) ).
Well played
!