Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I got an object where I keep track of several things that the user can fill out, delete, update, etc.

Now, when 'loading' such a project, I make an api call to my backend using axios to retrieve the specific data to send it back to the client. The api call looks like this:

axios.get(`/api/data/${this.$route.params.dataId}`)
  .then((response) => {

    //Why does this not work?
    this.nestedObject = response.data.object

    //This DOES work... Why?
    this.nestedObject.recipes = response.data.object.recipes
    this.nestedObject.cheffs= response.data.object.cheffs
  })
  .catch((err) => {
    console.log("error retrieving data: ", err);
  });

Whenever I just set this.nestedObject equal to the data that is coming from the server, it does not work. nestedObject is not updated with the new values. But when I set the individual entries in the object equal to the data that is coming from the server, it does work and nestedObject is updated appropriately. Why is that?

question from:https://stackoverflow.com/questions/66049289/how-do-i-set-nested-object-entries-coming-from-an-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
176 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...