Configuration is always empty when using window.Twitch.ext.configuration

Hi,

I have set a configuration panel that allows the broadcaster to set some parameters. These parameters get set OK with window.Twitch.ext.configuration.set().

However, using window.Twitch.ext.configuration to try and retrieve this info always returns an empty object.
Weird part is, I can get the configuration with postman by using twitch API.

Any idea how I can get the config using Twitch.ext.configuration?

Thanks

You do have something like


window.Twitch.ext.configuration.onChanged(() => {
    var broadcaster = window.Twitch.ext.configuration.broadcaster;
    if (broadcaster) {
        if (broadcaster.content) {
            var config = {};
            try {
                config = JSON.parse(broadcaster.content);
            } catch (e) {
                console.log(e);
            }

            //do stuff with config
        }
    }
});

To read the config you must use window.Twitch.ext.configuration.onChanged to trigger config to be loaded

That’s how I have it in my code, but config remains ‘undefined’ (exact same result when using your code from above).

Do I have to pass any auth parameters somewhere, maybe?

No

That could suggest you didn’t set the segment you think you did.

Or you might have the config service disabled on this version of the extension (version being an extension version, not a config version) and you wrote to a different version (if you have multiple versions).

So check the extension has the config service enabled in the console.
Reinstall the extension to the test channel.
And test it again

If you are testing in the rig, you might have set a different channel for the view than you get setting/getting against using postman. So check that too.

I have only one version and i’m testing on localhost (no rig).

Here is how the config is set, which I believe sets the segment to “broadcaster”.
window.Twitch.ext.configuration.set("broadcaster", '', streamerConfig);
with streamerConfig being some input from the broadcaster.

Here’s the API call that returns the correct data:
https://api.twitch.tv/extensions/[my_extension_id]/configurations/segments/broadcaster?channel_id=[my_test_channel_id]. It returns:

{
    "broadcaster:[my_test_channel_id]": {
        "segment": {
            "segment_type": "broadcaster",
            "channel_id": "[my_test_channel_id]"
        },
        "record": {
            "content": "test string config"
        }
    }
}

is "test string config" a string or a JSON encoded string?

Not that it should make a difference (I’ve only ever done JSON blobs never a “true” string)

I don’t see anything else obviously wrong.

And I’m assuming your onChanged isn’t “inside” another function? Which could potentially cause an issue. (not tested myself but worth to check, all mine are top level)
Also check your don’t have more than one call kicking about.

Yes it’s JSON encoded and onChanged is on top level. I have onContext and onAuthorized at top level, too, but I don’t think this can create a conflict?

Kinda at a loss :upside_down_face: I’m just including an API call in there for now; it’s clunky AF but seems to get the job done.

Yeah I’m out of the obvious ideas. Since similar calls work for me in a released extension.

Did you we try uninstalling the extension and reinstalling?

And might be worth cracking open dev tools and going digging see if ti throws up anything interesting

Just tried that but no luck here. I’m developing the extension with React, could this impact it at all?

I don’t know I don’t use react.

But it would seem unlikely since your logged a undefined anyway

May be worth stripping react out and trying a basic HTML/JS example instead to rule it out

Will try that, thanks Barry!