[Vuejs]-How to dynamically change vuejs Method based on route parameters?

0👍

The problem is the map creation when updating the Firestore document. When you write a map with literal object notation the keys are taken as strings, regardless of variables defined with the same name. Instead what you expected to happen is that the key picName to become the picName value instead of the string picName. See the example below for code wise explanation and a way to fix it.

picName = "foo"
downloadUrl = "bar"
dct1 = { picName: downloadUrl } 
console.log(dct1) // => { "picName": "bar" } (key as string)

// Solution
dct2 = {}
dct2[picName] = downloadUrl
console.log(dct2) // => { "foo": "bar" } (key as variable value)

EDIT: The code changed in the call to firestore update is not syntactically correct. Once the hashmap is created it should be directly passed to the update method. See the code below:

let dct2 = {}
dct2[picName] = downloadUrl
fb.restCollection.doc(rest.id).update(dct2)

Leave a comment