What Is Difference Between $http.get() Vs Axios.get() In Vue.js?
Solution 1:
The $http is a global variable probably you defined in your vuejs project, please search for $http in your project and you might find it's just the implementation of axios, which will give you an easy access to your axios library with global configuration.
axios is a library which capable of sending and receiving Http requests check it here axios library.
so in short answer they are the same
Solution 2:
As it can be seen in source code, the only thing that vue-axios plugin does is providing $http
property for Vue instance and components that use it.
This is a form of dependency injection and serves two purposes:
this.$http
can be accessed inside Vue components instead of carryingimport axios from './my-axios-instance'
everywhere, this is particularly useful in non-modular environments or when baseaxios
is refactored toaxios.create()
instance at some pointAxios instance can be swapped for a hierarchy of Vue components, e.g. configured with different base URL or headers for a feature module
Post a Comment for "What Is Difference Between $http.get() Vs Axios.get() In Vue.js?"