Admin: get sports list
This commit is contained in:
31
mpwo_client/src/actions/index.js
Normal file
31
mpwo_client/src/actions/index.js
Normal file
@ -0,0 +1,31 @@
|
||||
import mpwoApi from '../mwpoApi/index'
|
||||
|
||||
|
||||
export const setData = (target, data) => ({
|
||||
type: 'SET_DATA',
|
||||
data,
|
||||
target,
|
||||
})
|
||||
|
||||
export const setError = (target, error) => ({
|
||||
type: 'SET_ERROR',
|
||||
error,
|
||||
target,
|
||||
})
|
||||
|
||||
export function getData(target) {
|
||||
return function(dispatch) {
|
||||
return mpwoApi
|
||||
.getData(target)
|
||||
.then(ret => {
|
||||
if (ret.status === 'success') {
|
||||
dispatch(setData(target, ret.data))
|
||||
} else {
|
||||
dispatch(setError(target, ret.message))
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
throw error
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user