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
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
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•3y ago
Message Not Public
Sign In & Join Server To View
Sorry a bit new to this - what do you mean by a service? 🙂 @Duke
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ah okey, not fully comfortable with the concept but i kinda know what it is!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
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•3y ago
Message Not Public
Sign In & Join Server To View