[Vuejs]-VueJS – Http Requests – Parent or Child component?

0πŸ‘

βœ…

At least in my opinion I think the best you can do is build children components as simple as posible for reusability, I mean, imagine that you have a component named β€œNewsfeed” that show a lot of random stuff, you can use it in a main page for a social media website and for the profile page from someone like Facebook does, the only difference will be at the moment of fetch the data, they will not be the same but the component does, if you explicity make the component fetch the data it will not be reusable

I’m not a Senior or something like that but in my short experience I can say that.

0πŸ‘

First of all, Axios still makes use of Ajax.

More so, it depends on where and how the content being fetched would be needed.

If the content is going to be needed by other components in the same parent component or would be used by the parent component itself, then make your query in your parent component.

Else, your child component should handle its own queries and processes.

In simple terms, many things come into consideration when making such decisions. a more detailed explanation could help me figure out a better suggestion.

Leave a comment