簡體   English   中英

如何在獲取 javascript 中的 URL 時使用 where 條件?

[英]How to use where condition in fetch URL in javascript?

我在他們的 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)
        })

在控制台中看起來像這樣

Request URL: https://apiv4.ordering.co/v400/es-419-1/devyv4/users?mode=dashboard&params=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 的一部分或什么。

仔細查看您正在傳遞的 URL。 您需要使用 ? 定義搜索字符串的開頭?

fetch("https://....co/v400/path?mode=dashboard&params=id,name,lastname&where...")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM