查询参数twitch API

时间:2017-08-04 21:06:25

标签: javascript api xmlhttprequest

此查询有效,但我想添加一些optionnals参数。

Alert.prototype.getUserFollowedChannels = async function (user) {
        return new Promise((resolve, reject) =>{
            var xhr = new XMLHttpRequest();
            xhr.open('GET', 'https://api.twitch.tv/kraken/users/' + user+ '/follows/channels?client_id=' + this.clientId, true);
            //xhr.open('GET', 'https://api.twitch.tv/kraken/users/' + user+ '/follows/channels?client_id=' + this.clientId+'?limit=100', true); // try with what i want
            xhr.onreadystatechange = function () {
                if (xhr.readyState != 4 || xhr.status != 200) return;
                var follows = JSON.parse(xhr.responseText);
                if (follows) resolve(follows);
                else resolve("none");
            }
            xhr.send();
        })
}

我的查询文档:https://dev.twitch.tv/docs/v5/reference/users/#get-user-follows

1 个答案:

答案 0 :(得分:0)

您可以使用query-string

之类的内容