Configuration.set doesn't set value

Hi, I’m creating a small app, and when I try to set a value the value remains undefined:

const twitch = window.Twitch.ext;
const form = document.getElementById('form');

form.addEventListener('submit', (e) => {
  e.preventDefault();
  const option = document.getElementById("form-select");
  const value = option.value;
  console.log("submitted: ",JSON.stringify({'option': value}))
  const jsonString = JSON.stringify({'option': value});
  try{
    twitch.configuration.set('broadcaster', "", jsonString);
  } catch(e){
    console.log(e)
  }
  console.log(twitch.configuration);


});

The extension set value when submit form, I tried with different version values, and I enabled configuration service on extension options and tried with different options for Developer Writable Channel Segment Version and Broadcaster setting to empty both, “broadcaster” and “1”… etc

Thanks in advance :slight_smile:

Doing a set will not cause a reload of the configuration service.
Either update twitch.configuration yourself or reload the page.

So you would do a set
Reload the extension
Then check if the data is now present (which it should be)

.onChanged can only be called once it’s not recalled when the configuration service is updated. Since configuration is only loaded once, if you set it’s not loaded again

I tend to load configuration with onChanged, then copy the values into my own JS Object.
then if I do a set I’ll update my object as well as calling .set

If it’s not populated on load then you are not calling onChanged to populate

Still undefined when I reload the extension, should I fill something in the capabilities?

Assuming the set actually set as the user doing the set call is the broadcaster (or better)

Then this woukd suggest the configuration service is not enabled

You can also use the API to cross check whats enabled

Or a tool, like my Extension Developer Tools will check whats enabled and enable relevant functions

So here for example it checked whats enabled (via Get Extensions) and saw the Config service is but Send Chat isn’t (for example)

I already enabled, but I will test with your tool, thanks!

So

window.Twitch.ext.configuration.onChanged(() => {
    console.log(window.Twitch.ext.configuration.broadcaster);
});

Is still null?

Should see something like

image

(granted your configuration won’t be cat:cat)