Search code examples
javascriptjsongetjson

getJSON correct syntax for multiple property values stored in property name


I can not get multiple languages to work. Can someone please help me and show how should I write multiple choices for property name language?

If I write code like this, to show only Dota 2 games in English, everything works perfectly.

$(document).ready(function() {   
    $.getJSON( "https://api.twitch.tv/kraken/streams", 
        {
            game:"Dota 2",  
            language:'en'       
        },      
        function ( data ) {}

But if I try to add more languages and write code like this then it doesn't work:

$(document).ready(function() {   
    $.getJSON( "https://api.twitch.tv/kraken/streams", 
    {
        game:"Dota 2",  
        language:['en', 'de', 'fr', 'it', 'ru']
    },      
    function ( data ) {}

You can see JSON data on this link: https://api.twitch.tv/kraken/streams


Solution

  • You would need to make multiple calls to the API, one for English and another for languages (and then concatenate the lists of streams).

    check reference https://discuss.dev.twitch.tv/t/multilanguage-stream-filter/4790