Hi, you could use a trait for it, parent class or a helper function globally registered
Dealing with external API Responses
Greetings!
I completed the Laracasts tutorial "Build a Video Game Aggregator". Everything works fine, but there is one more thing that I want to improve.
My application makes a call to the IGDB API, which is a Twitch database that contains a lot of informations about games. Sometimes the API won't returns me all fields that I expect, so in my components I have a function called formatForView() that handles the API request and normalizes the output.
Since I need to repeat this function in my controllers and sometimes in my Livewire components, there is a easier way to do that? Maybe some pattern, or tutorial to handle and normalizes API responses?
You can check my code here: https://github.com/pedroroccon/gamefy
Thanks! Regards!
DRY it out and then use DataTransferObject/ValueObject to transfer that information.
Please or to participate in this conversation.