mutations: { addPhotos(state,photos){ state.photos.push(photos) } }
getters:{ // get photos array getPhotos(state){ return state.photos; } }
actions:{ { const response = await fetch("https://api.pexels.com/v1/search?query=car"); const data = await response.json(); commit("getPhotos", data); } }
  • How to get data stored in states using getters?

Web developer, Life Café https://medium.com/life-cafe , Curious Soul, twitter at @amjohnphilip,

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store