HTTPClient vs HTTPRequest? [Godot 4.1]
I started coding an API interface class for Spotify as a custom class in GDScript recently, and I've already changed how I request things twice. Skip to the end for the meat and potatoes, but first some context.
My first attempt looked something like this:
Ripped straight from the HTTPRequest Example in the docs.
However, this proved problematic as I struggled to return the values I wanted. I then finally watched a tutorial on youtube that was in Godot 3.5 and I noticed that he didn't route the request_completed signal to a different function, instead awaiting its result in-function like so:
This is where I am right now, but the below line of code was bothering me:
Spurred by my annoyance, I started taking a closer look at HTTPClient and HTTPRequest documentation, and soon I realized that HTTPClient might be better for what I'm trying to do. Eg:
One HTTPClient to rule them all.
I only have two hosts to connect to ever with this class: accounts.spotify.com and api.spotify.com. I figure, rather than use HTTPRequest for every single api-call function (which uses HTTPClient internally anyway), it would be more efficient to make sure I'm only using one HTTPClient ever.
My question(s) are this: Which should I use? Did I miss the mark for all of my attempts? Is there some better way to be doing this?