Twitch API in an extension

You shouldn’t wrap it in document.addEventListener("DOMContentLoaded", function(){

But otherwise your code seems correct, other than you didn’t parse the result to JSON but I don’t use XHR

The user ID doesn’t need an API call, the userID is in window.Twitch.ext.viewer.id - https://dev.twitch.tv/docs/extensions/reference/#helper-viewer if the user has logged into the extension.