- In my previous post we have learnt creating Fake JSON API for Sorting and Paging using JSON-SERVER node package module for rapid application development.
- In this demo, “We will learn to use searching with JSON-SERVER NPM module”.
- The data.json file contains the student record for create a Fake API.The content of data.json file is as follows.
{
"students": [
{
"id": 123,
"name": "Sandeep",
"subject": "Computer",
"marks": 23
},
{
"id": 193,
"name": "Raja",
"subject": "Mathematics",
"marks": 25
},
{
"id": 223,
"name": "Smith",
"subject": "Geography",
"marks": 20
},
{
"id": 313,
"name": "Sandeep",
"subject": "History",
"marks": 21
}
]
}
- The fake JSON-SERVER API is running on port 3000 and can be accessed through HTTP call.The following screenshot.
- Now if we want to search for a string we need use a query parameter q with the search string.Let’s search for a string sa then the query parameter will be q=sa can be appended to the URL.The following screenshot shows the result of JSON API for search string sa.
- The log message by JSON server is as follows.

