[Vuejs]-Assign JSON data/response (api response) to itemsArray dynamically

0👍

After a day of struggle and searching all over the places; finally found the solution.

define an empty array and change from const to var to bind the data dynamically at later stage

var someData = () => [{}]

.
.
.

and inside export default { } call api in mounted method


mounted() {
    axios({ method: "GET", "url": "https://localhost:80/api/values" }).then(result => {
                  this.items = () => JSON.parse(result.data);

                }, error => {
                    console.error(error);
                    this.error= error;
                });
    }

Leave a comment