C
C#•2y ago
big OOF

Api question

Hi, I want to create a API that return data from another API, my question is regarding how to structure the code. You have the API controller with endpoints that gets called and returns a value. Where should i place the function that makes the call towards the second api? 1. It dosent sound too good to have it inside the api controller? 2. Should i create another class that hold all functions needed? 3. Add another class library project? 4. Include methods in the model classes? Thanks in advance 🙂
9 Replies
Jayy
Jayy•2y ago
it depends on how large of a surface are you are hitting on the external api, generally youll have a service class that wraps the calls but if its a more advanced api etc you might need a seperate project to fully encompass it
big OOF
big OOF•2y ago
What do you mean by surface? This will only be a small projekt so it will only make a single call towards the second api.
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
big OOF
big OOF•2y ago
Sorry a bit new to this - what do you mean by a service? 🙂 @Duke
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
big OOF
big OOF•2y ago
Ah okey, not fully comfortable with the concept but i kinda know what it is!
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
big OOF
big OOF•2y ago
Okey thank you! I will have to try and update myself with dpi and create a example. The reason it is called service, is it just thanks to it works like a service/supportive class? 🙂
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View