From 6f78b33680a3a8a45c1afe1d96c82ae0e96ac15b Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Fri, 10 Jan 2025 19:16:38 +0100 Subject: [PATCH] prevent hiddenFields of undefined --- src/Model.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Model.js b/src/Model.js index ec770a2..d964423 100644 --- a/src/Model.js +++ b/src/Model.js @@ -53,12 +53,13 @@ export default class Model { autoSave: options.autoSave ?? defaults.autoSave ?? null, autoRefresh: options.autoRefresh ?? defaults.autoRefresh ?? false, pre: options.pre ?? defaults.pre ?? null, + hiddenFields: options.hiddenFields ?? defaults.hiddenFields ?? [], post: options.post ?? defaults.post ?? null }; this.#store = null; this.#includes = {}; this.#axios = this.options.axios || axios; - this.#hiddenFields = this.options.hiddenFields || []; + this.#hiddenFields = this.options.hiddenFields; this.#loadFunction = this.options.load || null; if (!name || !options) { @@ -270,7 +271,7 @@ export default class Model { }; #removeHiddenFields = (json) => { - for (let attribute of this.#hiddenFields ?? []) { + for (let attribute of this?.#hiddenFields ?? []) { delete json[attribute]; }