Skip to content

Commit a37114c

Browse files
maximilianmikusfago
authored andcommitted
LDP-697 Move menu endpoint to config.
1 parent 430e17b commit a37114c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const { resolve } = require('path')
44
module.exports = async function (moduleOptions) {
55
const defaultOptions = {
66
baseURL: process.env.DRUPAL_BASE_URL || 'http://localhost:8888',
7+
menuEndpoint: 'menu_items',
78
addRequestFormat: 'custom_elements',
89
addRequestContentFormat: false,
10+
addNoRequestRewriteForMenus: true,
911
addVueCompiler: true,
1012
useProxy: 'dev-only',
1113
axios: {}

lib/plugin.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DrupalCe {
3131
* @returns {Promise<void>}
3232
*/
3333
async fetchMenu (name, config = {}) {
34-
await this.context.store.dispatch('drupalCe/getMenu', { name, config, context: this.context, axios: this.$axios })
34+
await this.context.store.dispatch('drupalCe/getMenu', { name, config, context: this.context, options: this.options, axios: this.$axios })
3535
}
3636

3737
/**
@@ -115,10 +115,12 @@ const storeModule = {
115115
addMessage ({ commit }, message) {
116116
commit('addMessage', message)
117117
},
118-
async getMenu ({ commit }, { name, config, context, axios }) {
118+
async getMenu ({ commit }, { name, config, context, options, axios }) {
119119
config.params = config.params ?? {}
120-
config.params.no_request_rewrite = 1
121-
const path = `menu_items/${name}`
120+
if (options.addNoRequestRewriteForMenus) {
121+
config.params.no_request_rewrite = 1
122+
}
123+
const path = `${options.menuEndpoint}/${name}`
122124
try {
123125
const { data } = await axios.get(path, config)
124126
commit('setMenu', { name, data })

0 commit comments

Comments
 (0)