Example of Web Apps that use a GET request?

I’m a bit lost trying to figure the API out this last week, I’m able to figure out how to do a fetch and receive the data back with vanilla JS, but I can’t quite figure out how to have a button a visitor clicks, that will run through the authorization process, and redirect afterwards. For example, using a GET request to print out the bit leaderboard in a simple list.

I’m familiar with express, node, mongo, and templating engines, but I can’t quite piece together something as simple as running a GET request from a button, and returning a new page (via EJS or some other templating engine). I’ve been browsing github for examples, or trying to figure out the node example from the docs, but it’s a struggle!

Below is what I’d like to go for (just to learn), I don’t expect help making the app itself, but does anyone have recommendations for simple repositories I can look through?

heres a “practical” example

It doesn’t do the DB call but it shows how you’d get a token and use that token to see if another user logging into the site/tool is a moderator or not.

You would not normally do a “plain vanilla JS Fetch request” here for the work flow described in you image.

Sure you would use a button + vanilla JS fetch request to instruct the backend to go collect moderators.
But you wouldn’t use a button + vanilla JS fetch request to go collect moderators

1 Like

Oh man this GitHub repo is the best, I think something like the authentication > oidc_authentication example is more what I’m looking for.

The end goal is to just have a button a twitch broadcaster can click, they authorize the app, and then it displays their moderator list. Sorry about the flow-chart, not something I’m used to doing. As for the fetch, I have it setup so it does a vanilla JS fetch and stores it on the mongoDB, and it at least works for the bearer token I already have from my personal twitch account, though obviously still figuring out how to allow anyone to use it. But what do you mean by:

you wouldn’t use a button + vanilla JS fetch request to go collect moderators

Your button would normally call your backend and then the backend calls Twitch API.

Your OP suggested you would call Twitch directly instead of via the backend.

Traditionally, unless using implicit auth, you’d call your backend and your backend calls Twitch

1 Like