Proper way to load JSON data



  • I have created an app that has up till now used the quasar store to load (getters) data, and manipulate that data (actions/mutations). All fine and well, but I really want to access the data from a database which I have a REST api server wrapped around. This works great and I have no issues with it.
    What I am unsure of is what is the preferred or recommended way to work with the data in quasar, do I…

    1. Use the ‘store’ to retrieve the information and make it available through the ‘store’. ie. use getters/actions/mutations working with Axios to GET and PUT data.
    2. Forget about the ‘store’ all together and just load the data via Axios in the mounted section of the individual vue files.
    3. Another way???

    I am struggling to get my head around how I implement no 1. eg. I can’t import data in the getter function. Quasar says the data can only be changed in a mutation, which I know is correct. Just not sure how to go from there.

    Anyone with a similar project?



  • I’m going to assume you don’t know the “store” is just Vuex. And, you should put most of your API calls in the Actions of your store modules.

    https://vuex.vuejs.org/ (watch the video 🙂 )

    Scott


Log in to reply