JS Search Game API V5

For some reason im getting error 400 when i search with Client-ID and Oauth

        $.ajax({
            url: 'https://api.twitch.tv/kraken/search/games',
            type: 'GET',
            data: {query: game.value},
            headers: {
                'Accept': 'application/vnd.twitchtv.v5+json',
                'Client-ID': 'clientid'
            },
            success: function(data) {
                console.log(data);
                $.each(data.games, function(){
                    console.log(this.name);
                    opt.append(new Option(this.name, this.name));
                });
            }
        });

The Body response will contain more information.

I believe the issue is because the request should be:

 $.ajax({
             url: 'https://api.twitch.tv/kraken/search/games?query=' + game.value,
             type: 'GET',
             headers: {
                 'Accept': 'application/vnd.twitchtv.v5+json',
                 'Client-ID': 'clientid'
             },
             success: function(data) {
                 console.log(data);
                 $.each(data.games, function(){
                     console.log(this.name);
                     opt.append(new Option(this.name, this.name));
                 });
             }
         });

Should be a query string argument not a body/form item

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.