如何在javascript中使用获取URL中的where条件?
我在他们的sdk中使用了第三方api,他们提供了基于where条件获取数据的选项如何在javascript中使用获取URL中的where条件?,javascript,arrays,json,angularjs,Javascript,Arrays,Json,Angularjs,我在他们的sdk中使用了第三方api,他们提供了基于where条件获取数据的选项 Ordering.users.all({ mode: 'dashboard', params: 'id,name,lastname', where: [ { attribute: 'level', value: {
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)
})
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}}]
在控制台中似乎是这样的
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)
})
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}}]
但是当我在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)))))
我如何在url中使用它?用户启动searchParams后需要一个
?
,atm您有一个&
不确定是否遗漏了url的一部分或什么。用户启动searchParams后需要一个?
,atm您有一个&
不确定是否遗漏了URL的一部分或什么。仔细查看您传递的URL。您需要使用?
fetch(“https://....co/v400/path?mode=dashboard¶ms=id,name,lastname&where…)
仔细查看您传递的URL。您需要使用?
fetch(“https://....co/v400/path?mode=dashboard¶ms=id,name,lastname和where…)