yapi/client/reducer/modules/follow.js

42 lines
724 B
JavaScript
Raw Normal View History

2017-08-15 12:08:59 +08:00
import axios from 'axios';
// Actions
const GET_FOLLOW_LIST = 'yapi/follow/GET_FOLLOW_LIST';
2017-08-19 15:18:55 +08:00
const DEL_FOLLOW = 'yapi/follow/DEL_FOLLOW';
2017-08-15 12:08:59 +08:00
// Reducer
const initialState = {
data: []
};
export default (state = initialState, action) => {
switch (action.type) {
case GET_FOLLOW_LIST: {
return {
...state,
data: action.payload.data.data
};
}
default:
return state;
}
};
2017-08-19 15:18:55 +08:00
// 获取关注列表
2017-08-15 12:08:59 +08:00
export function getFollowList(uid) {
return {
type: GET_FOLLOW_LIST,
payload: axios.get('/api/follow/list', {
params: { uid }
})
}
}
2017-08-19 15:18:55 +08:00
//
export function delFollow(id) {
return {
type: DEL_FOLLOW,
payload: axios.post('/api/follow/del', { id })
}
}