Skip to content
Snippets Groups Projects
Commit 4c43fdaf authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

fix: use lodash merge to merge request init objects

We have properties like header, that contain objects that need to be
merged recursively.
parent 532a96f0
No related branches found
No related tags found
No related merge requests found
import { defineStore } from 'pinia'
import { computed, readonly, ref, Ref } from 'vue'
import { merge } from 'lodash'
type ID = number | string
......@@ -100,11 +101,14 @@ export function createExtendableAPI<T extends APIObject>(
customRequestData: RequestInit | undefined,
defaultRequestData?: RequestInit | undefined,
) {
return new Request(url, {
...(defaultRequestData ?? {}),
...(options?.getRequestDefaults?.() ?? {}),
...(customRequestData ?? {}),
})
return new Request(
url,
merge(
options?.getRequestDefaults?.() ?? {},
defaultRequestData ?? {},
customRequestData ?? {},
),
)
}
function reset() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment