From 0d437facc1ec6c2599d3b0f744efcdb1c25e1bb4 Mon Sep 17 00:00:00 2001 From: Stuart Clark Date: Thu, 2 Nov 2023 12:05:23 +1100 Subject: [PATCH] fix(#679): add nuxt auth axios instance to plugin --- packages/menu/templates/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/menu/templates/plugin.js b/packages/menu/templates/plugin.js index bc4386018..9d09a99cc 100644 --- a/packages/menu/templates/plugin.js +++ b/packages/menu/templates/plugin.js @@ -1,6 +1,6 @@ import { DruxtMenu } from 'druxt-menu' -export default (context, inject) => { +export default ({ app }, inject) => { const baseUrl = '<%= options.baseUrl %>' const options = {} @@ -12,6 +12,14 @@ export default (context, inject) => { options.menu = <%= JSON.stringify(options.menu) %> <% } %> + <% if (typeof options.axios === 'object') { %> + // Axios settings. + options.axios = <%= JSON.stringify(options.axios) %> + <% } else { %> + // Use the @nuxtjs/axios module Axios instance. + options.axios = app.$axios + <% } %> + const druxtMenu = new DruxtMenu(baseUrl, options) inject('druxtMenu', druxtMenu) }