import { getIndex } from "../services" ; export default { namespace : 'home' , state : { init : false , search_tips : [ ] , recommend_list : [ ] } , effects : { * getIndex ( action , { call , put } ) { const { callback } = action ; try { const response = yield call ( getIndex ) ; console . log ( response ) ; yield put ( { type : 'save' , payload : { init : true , ... response . data } } ) ; callback && callback ( response ) ; } catch ( e ) { yield put ( { type : 'save' , payload : { error : e } } ) ; } } } , reducers : { save ( state , { payload } ) { return { ... state , ... payload } ; } , } , } ;