Skip to content

Commit d88c29c

Browse files
fix: enhance addSettings method to handle stack variables and live preview settings
1 parent ffd2c7f commit d88c29c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/stack/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,19 @@ export function Stack (http, data) {
631631
* .then((settings) => console.log(settings))
632632
*
633633
*/
634-
this.addSettings = async (variables = {}) => {
634+
this.addSettings = async (stackVariables = {}) => {
635635
try {
636-
const response = await http.post(`${this.urlPath}/settings`, { stack_settings: variables },
637-
{ headers: {
638-
...cloneDeep(this.stackHeaders)
639-
} })
636+
const payloadBody = (
637+
'stack_variables' in stackVariables ||
638+
'live_preview' in stackVariables ||
639+
'rte' in stackVariables
640+
)
641+
? { stack_settings: stackVariables }
642+
: { stack_settings: { stack_variables: stackVariables } }
643+
644+
const response = await http.post(`${this.urlPath}/settings`, payloadBody, { headers: {
645+
...cloneDeep(this.stackHeaders)
646+
} })
640647
if (response.data) {
641648
return response.data.stack_settings
642649
} else {

0 commit comments

Comments
 (0)