-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.js
39 lines (33 loc) · 887 Bytes
/
store.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import fetch from 'isomorphic-fetch'
import config from 'config'
const INST_RECENT = 'https://api.instagram.com/v1/users/self/media/recent/'
const state = {
InstagramPhotos: {}
}
const getters = {
getInstagramFeed: (state) => state.InstagramPhotos
}
const actions = {
updateInstagramPhotos (context, token, count) {
if (typeof navigator !== 'undefined' ? navigator.onLine : true) {
return fetch(INST_RECENT + '?access_token=' + token + '&count=' + config.instagram.count).then((response) => {
return response.json()
}).then((jsonResponse) => {
if (jsonResponse.meta.code === 200) {
context.commit('updateInstagramPhotos', jsonResponse.data)
}
})
}
}
}
const mutations = {
updateInstagramPhotos (state, data) {
state.InstagramPhotos = data
}
}
export default {
state,
getters,
actions,
mutations
}