DEV Community

Discussion on: Let's talk about an unnecessary but popular Vue plugin

Collapse
 
heftyhead profile image
heftyhead

In my opinion, it's a valid approach. Declaring global variables is generally considered a bad coding practice. However, I feel like if you don't abuse it and you are not working on a really big project it doesn't matter as much.

I think that the advantage of using the prototype approach is that usually, you want to make API calls in relation to the component life cycles and events. So making axios available only by components code ensures that API calls are made only in the right moment(you can still pass axios as an argument to a function or a class). This is a quite broad topic so you can easily argue that what I wrote is not always true. Nevertheless, I hope that you can see some advantages of using the prototype approach.

Collapse
 
romanpaprotsky profile image
Roman Paprotsky

Thank you for clarification.