Skip to content

Commit

Permalink
fix(plugin): always get global $nuxt while loading (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
erraX authored May 26, 2020
1 parent 0957082 commit e848b9d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import Axios from 'axios'
import defu from 'defu'
<% if (options.retry) { %>import axiosRetry from 'axios-retry'<% } %>

const $nuxt = typeof window !== 'undefined' && window['$<%= options.globalName %>']

// Axios.prototype cannot be modified
const axiosExtra = {
setBaseURL (baseURL) {
Expand Down Expand Up @@ -128,7 +126,10 @@ const setupProgress = (axios) => {
set: () => { }
}

const $loading = () => ($nuxt && $nuxt.$loading && $nuxt.$loading.set) ? $nuxt.$loading : noopLoading
const $loading = () => {
const $nuxt = typeof window !== 'undefined' && window['$<%= options.globalName %>']
return ($nuxt && $nuxt.$loading && $nuxt.$loading.set) ? $nuxt.$loading : noopLoading
}

let currentRequests = 0

Expand Down

0 comments on commit e848b9d

Please sign in to comment.