Asked By: Anonymous
I’m writing a MVC program which downloads the data from an API. I have finished a util class for the http service to receive the data from the API. Now I’m confusing in a MVC framework, should I call the http util method in the Model or Controller?
Answered By: Anonymous
I’d implement a separate service class that’s used by either by the controller or model to fetch such information. Ealier it was thought that model is about the business logic, so in that sense it would be used by that – nowadays I think having the controller use it would be more common choice.
I think services are a layer of its own, but there are different opinions about it. There’s a (closed) discussion "Where do services go in MVC" here which is about that topic.