1

I am working on a logic in my Vue SPA app that pulls data from an API the first time a certain source is called. Since the process would be repeated frequently, I want to store this once pulled data set in my store js.

export default {
  data() 
    return {
      data: ''
    }
  },
  //...
  async mounted() {
    if (store.myFetchedData) {
      this.data = store.myFetchedData;
    } else {
      this.data = await this.getDataFromApi()
      store.myFetchedData = this.data;    
    }
    console.log(this.data)
  },
  // ..
}

On the second run, I expect an object {id: 1, name: "hello world",...} to be output. Instead I get a proxy object.

Proxy { <target>: (3) [...], <handler>: {...} }

What does this proxy object mean? And what do I have to do to change that? Thanks in advance! Max

8
  • @JaromandaX You mean I should work with getters and setters, right? Commented Oct 20, 2022 at 8:56
  • @JaromandaX I updated my question. Data is a member var of the componente. Commented Oct 20, 2022 at 9:01
  • 1
    I see, you posted code that is not like the code you have an issue with - at least that's cleared up Commented Oct 20, 2022 at 9:06
  • 1
    Check the answer to this question: stackoverflow.com/questions/69202886/… Commented Oct 20, 2022 at 9:23
  • 1
    @JoséA.Zapata Thank you José! This link i very helpful :-) With all other comments and i found good answers i have a good overview what a proxy is. Commented Oct 20, 2022 at 9:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.