[英]How to use where condition in fetch URL in javascript?
I am using third party api in their sdk they have given option to fetch data on the base of where condition like this我在他们的 sdk 中使用第三方 api 他们已经给出了在这样的条件基础上获取数据的选项
Ordering.users.all({
mode: 'dashboard',
params: 'id,name,lastname',
where: [
{
attribute: 'level',
value: {
condition: '=',
value: 4,
}
}
]
},function (res) {
if (!res.error) {
$scope.drivers_filter = res.result
} else MyAlert.show(res.result)
})
in the console it seems like this在控制台中看起来像这样
Request URL: https://apiv4.ordering.co/v400/es-419-1/devyv4/users?mode=dashboard¶ms=id,name,lastname&where=[{%22attribute%22:%22level%22,%22value%22:{%22condition%22:%22=%22,%22value%22:4}}]
but when i use this url in fetch()
it doesn't work但是当我在
fetch()
中使用这个 url 时它不起作用
fetch("https://apiv4.ordering.co/v400/en/devyv4/users&where[{%22attribute%22:%22level%22,%22value%22:{%22condition%22:%22=%22,%22value%22:4}}]", {
method: "GET",
headers: {
"x-api-key": ""
}
}).then(r => r.json().then(data => (alert(JSON.stringify(data.result)))))
How i can use this in url?我如何在 url 中使用它?
You need a ?
你需要一个
?
after users to start the searchParams, atm you have a &
not sure if you missed part of the URL or what.在用户启动 searchParams 后,atm 你有一个
&
不确定你是否错过了 URL 的一部分或什么。
Look closely at the URL you're passing.仔细查看您正在传递的 URL。 You need to define the start of your search string with
?
您需要使用 ? 定义搜索字符串的开头
?
fetch("https://....co/v400/path?mode=dashboard¶ms=id,name,lastname&where...")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.