Vuefire Firebase update issues -


i'm having som issues updating firebase vuefire. m trying use following method, yells @ me if leave field blank (which supposed happen in setup) idea why gets mad if .update blank field?

error: uncaught error: firebase.update failed: first argument contains undefined in property 'businesses.somebusiness.video'

updatepost(post) {         postsref.child(post['.key']).update({           name: post.name,           video: post.video,           story: post.story,           cover: post.cover,           card: post.card         })       }, 

at 1 point had above re-written so:

updatepost: function (post) {         const businesschildkey = post['.key'];         delete post['.key'];         /* set updated post value */         this.$firebaserefs.posts.child(businesschildkey).set(post)       }, 

it worked amazingly deleting key seemed cause weird ordering issues in vue. prefer stick top method if can find way not have trow error if 1 left blank.

according this post,

when pass object firebase, values of properties can value or null (in case property removed). can not undefined, you're passing in according error.

your error message suggests post.video's value undefined. can use logical-or provide fallback value so:

  video: post.video || null, 

that means whenever post.video has false-y value, expression evaluate null. catch empty string or numeric 0, though. more precisely correct, should use

  video: typeof post.video === 'undefined' ? null : post.video, 

if need check many values, can write function it:

function nullifundefined(value) {   return typeof value === 'undefined' ? null : value; } 

then expression be

  video: nullifundefined(post.video), 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -