如何使用特定的搜索查询过滤对 json 服务器的 get 请求?

Ste*_*ler 7 javascript json json-server

我已经安装了 Json 服务器。对此服务器的获取请求正在传递预期的数据,但现在我想向我的请求添加一些搜索查询。但结果还是一样。我不知道我在这里犯了什么错误。

这是我的请求: http://localhost:3000/people?age=22

我也尝试过: http://localhost:3000/people?customer.age=22但结果仍然是所有数据。

那是我的 JSON 文件:

 {
  "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"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

小智 18

尝试

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

[
  {
    "id": 1,
    "name": "Stefan Winkler",
    "phone_number": "017692601589",
    "age": "22",
    "education": "High School"
  }
]
Run Code Online (Sandbox Code Playgroud)

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

[
  {
    "id": 2,
    "name": "Christoph Huber",
    "phone_number": "094462649",
    "age": "42",
    "education": "nothing"
  }
]
Run Code Online (Sandbox Code Playgroud)