From 702397eed3e39e18b73102c3ac54a8ca59354a9a Mon Sep 17 00:00:00 2001 From: Pierce Date: Tue, 24 Oct 2023 14:51:47 -0700 Subject: [PATCH] better field handling --- src/lib/Content.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/Content.ts b/src/lib/Content.ts index 8939ef2..6d43c41 100644 --- a/src/lib/Content.ts +++ b/src/lib/Content.ts @@ -90,9 +90,15 @@ export class Content { async modify(contentId: number, sectionId: number, options: ContentDTO, language: string = 'en'): Promise { let existingContent = await this.get(contentId, sectionId, language) if (!existingContent) throw Error(`Content ${contentId} in section ${sectionId} does not exist`) - existingContent.elements = { ...existingContent.elements, ...options.elements } const response = await this.client.call('POST', `${ContentEndpoint}/${sectionId}/${contentId}/${language}`, { - body: existingContent + body: { + ...existingContent, + ...options, + elements: { + ...existingContent.elements, + ...options.elements + } + } }) return await response.json() }