|
@@ -0,0 +1,25 @@
|
|
|
+import Vuex from 'vuex'
|
|
|
+
|
|
|
+const createStore = () => {
|
|
|
+ return new Vuex.Store({
|
|
|
+ state: {
|
|
|
+ headlines: []
|
|
|
+ },
|
|
|
+ mutations: {
|
|
|
+ setHeadLines (state, headlines) {
|
|
|
+ state.headlines = headlines
|
|
|
+ }
|
|
|
+ },
|
|
|
+ actions: {
|
|
|
+ async loadHeadLines ({ commit }, apiUrl) {
|
|
|
+ const { articles } = await this.$axios.$get(apiUrl)
|
|
|
+ commit('setHeadLines', articles)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getters: {
|
|
|
+ headlines: state => state.headlines
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+export default createStore
|