Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I filter a get request to a json-server with specific search queries?

I have installed a Json-Server. Get-Requests to this server are delivering the expected data but now I want to add some search queries to my request. But the result is still the same. I don't know whats my mistake here.

Here is my request: http://localhost:3000/people?age=22

I also tried it with: http://localhost:3000/people?customer.age=22 but the result is still all data.

Thats my JSON-File:

 {
  "customer": [
    {
      "id": 1,
      "name": "Stefan Winkler",
      "phone_number": "017692601589",
      "age": "22",
      "education": "High School"
    },
    {
      "id": 2,
      "name": "Christoph Huber",
      "phone_number": "094462649",
      "age": "42",
      "education": "nothing"
    },
    {
      "id": 3,
      "name": "Michael Unholer",
      "phone_number": "093862649",
      "age": "12",
      "education": "Realschule"
    }
  ]
}
like image 621
Stefan Winkler Avatar asked Jun 17 '19 14:06

Stefan Winkler


1 Answers

try

http://localhost:3000/customer?age=22

[
  {
    "id": 1,
    "name": "Stefan Winkler",
    "phone_number": "017692601589",
    "age": "22",
    "education": "High School"
  }
]

http://localhost:3000/customer?name_like=rist

[
  {
    "id": 2,
    "name": "Christoph Huber",
    "phone_number": "094462649",
    "age": "42",
    "education": "nothing"
  }
]
like image 72
Euclides Okamoto Avatar answered Nov 14 '22 21:11

Euclides Okamoto