Skip to content

Commit d42623d

Browse files
authored
fix: MOP-213: URL params missing from fetchPage key (#356)
* improve: MOP-213: Add query key to fetchPage * MOP-213: Update params * MOP-213: Add unref
1 parent 2e33063 commit d42623d

File tree

1 file changed

+6
-2
lines changed
  • src/runtime/composables/useDrupalCe

1 file changed

+6
-2
lines changed

src/runtime/composables/useDrupalCe/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Ref, ComputedRef, Component } from 'vue'
55
import { getDrupalBaseUrl, getMenuBaseUrl } from './server'
66
import type { UseFetchOptions } from '#app'
77
import { callWithNuxt } from '#app'
8-
import { useRuntimeConfig, useState, useFetch, navigateTo, createError, h, resolveComponent, setResponseStatus, useNuxtApp, useRequestHeaders, ref, watch, useRequestEvent, computed, useHead, defineComponent } from '#imports'
8+
import { useRuntimeConfig, useState, useFetch, navigateTo, createError, h, resolveComponent, setResponseStatus, useNuxtApp, useRequestHeaders, ref, unref, watch, useRequestEvent, computed, useHead, defineComponent } from '#imports'
99

1010
export const useDrupalCe = () => {
1111
const config = useRuntimeConfig().public.drupalCe
@@ -128,7 +128,11 @@ export const useDrupalCe = () => {
128128
const serverResponse = useState('server-response', () => null)
129129
// Remove trailing slash from path key as it might cause issues in SSG.
130130
const sanitizedPathKey = path.endsWith('/') && path !== '/' ? path.slice(0, -1) : path
131-
useFetchOptions.key = `page-${sanitizedPathKey}${skipDrupalCeApiProxy ? '-direct' : '-proxy'}`
131+
const params =
132+
Object.keys(useFetchOptions.query || {}).length > 0
133+
? `?${new URLSearchParams(unref(useFetchOptions.query)).toString()}`
134+
: ''
135+
useFetchOptions.key = `page-${sanitizedPathKey}${params}${skipDrupalCeApiProxy ? '-direct' : '-proxy'}`
132136
let page = null
133137
const pageError = ref(null)
134138

0 commit comments

Comments
 (0)