Skip to content

Commit

Permalink
fix(#679): add nuxt auth axios instance to plugin (#680)
Browse files Browse the repository at this point in the history
* fix(#679): add nuxt auth axios instance to plugin

* chore(#679): add changeset
  • Loading branch information
Decipher authored Nov 2, 2023
1 parent 4ef4189 commit 86c8235
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wise-months-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-menu": patch
---

feat(#679): Adds Nuxt Auth Axios instance to the DruxtMenu plugin to ensure correct results are provided when authenticated.
10 changes: 9 additions & 1 deletion packages/menu/templates/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DruxtMenu } from 'druxt-menu'

export default (context, inject) => {
export default ({ app }, inject) => {
const baseUrl = '<%= options.baseUrl %>'
const options = {}

Expand All @@ -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)
}

0 comments on commit 86c8235

Please sign in to comment.