File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ function axiosModule (_moduleOptions) {
9494 options . browserBaseURL = https ( options . browserBaseURL )
9595 }
9696
97+ // globalName
98+ options . globalName = this . nuxt . options . globalName || 'nuxt'
99+
97100 // Register plugin
98101 this . addPlugin ( {
99102 src : path . resolve ( __dirname , 'plugin.js' ) ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import Axios from 'axios'
22import defu from 'defu'
33< % if ( options . retry ) { % > import axiosRetry from 'axios-retry' < % } % >
44
5- const globalName = ' $<%= globalName %>'
5+ const $nuxt = typeof window !== 'undefined' && window [ ' $<%= options. globalName %>']
66
77// Axios.prototype cannot be modified
88const axiosExtra = {
@@ -128,7 +128,7 @@ const setupProgress = (axios) => {
128128 set : ( ) => { }
129129 }
130130
131- const $loading = ( ) => ( window [ globalName ] && window [ globalName ] . $loading && window [ globalName ] . $loading . set ) ? window [ globalName ] . $loading : noopLoading
131+ const $loading = ( ) => ( $nuxt && $nuxt . $loading && $nuxt . $loading . set ) ? $nuxt . $loading : noopLoading
132132
133133 let currentRequests = 0
134134
You can’t perform that action at this time.
0 commit comments