Skip to content

Commit

Permalink
better field handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierce01 committed Oct 24, 2023
1 parent 7e443f6 commit 702397e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,15 @@ export class Content {
async modify(contentId: number, sectionId: number, options: ContentDTO, language: string = 'en'): Promise<ContentDTO> {
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()
}
Expand Down

0 comments on commit 702397e

Please sign in to comment.