0

So I have a data options like this

data() {
    return {
      userPayload: {
        description: '',
        languageCodes: [],
        facebookUrl: '',
        youtubeUrl: ''
      },
    }
  },

Later I applied some functions to fill out each attributes in data. Then when I want to submit the data using handleSaveData(), I passed this userPayload object to axios and turns out it's only read the value of description attributes.

handleSaveData() {
...
const userPayload = {
   description: this.userPayload.description,
   profile: {
     languageCodes: this.userPayload.languageCodes,
     facebookUrl: this.userPayload.facebookUrl,
     youtubeUrl: this.userPayload.youtubeUrl
   }
}

console.log(this.userPayload)
// this one contains value of all attributes

console.log(userPayload)
// this one only shows value of description attributes, while the others are empty string or empty array
// i expect it also return value of another attributes
// because i already access it with this.userPayload.{attributeName}

}

this.userPayload value

userPayload value

I already tried out deepClone userPayload object but it doesn't work

  • Don't use console for debugging. Use a proper debugger. It's not evident that values exist at the time when you access them. Everything suggests that the aren't. – Estus Flask Jul 17 '21 at 17:28
  • Possible duplicate of https://stackoverflow.com/questions/17546953/cant-access-object-property-even-though-it-shows-up-in-a-console-log – Estus Flask Jul 17 '21 at 17:28
  • @EstusFlask thank you, i already check it with debugger and found the problem – Muhammad Azmi Jul 24 '21 at 01:49

0 Answers0