gpt4 book ai didi

javascript - 如何使用特定搜索查询过滤对 json-server 的获取请求?

转载 作者:行者123 更新时间:2023-12-04 12:42:33 25 4
gpt4 key购买 nike

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

这是我的要求:
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"
}
]
}

最佳答案

尝试

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"
}
]

关于javascript - 如何使用特定搜索查询过滤对 json-server 的获取请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56633899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com