Curl Command in Javascript

You either use the oAuth flow to get the users access token. Either via Implicit or regular oAuth

Or you make your front end call your backend and then the backend uses an App Access Token to call Twitch (for public data).

This is an example of using pure Client Side JavaScript to authenticate and call the API

Demo: https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/
Code: https://github.com/BarryCarlyon/twitch_misc/tree/master/authentication/implicit_auth