2017-07-18 70 views
0

saga.js终极版 - 传奇 '叫' 没有定义没有民主基金

import { delay } from 'redux-saga' 
import { put, takeLatest, all } from 'redux-saga/effects' 
import axios from 'axios'; 

function fire(data) { 
    return axios.post('http://localhost:3131/createUserBusinessInfo', data).then(function (response) { 
     return response; 
    }).catch(function (error) { 
     return error; 
    }); 
} 

export function* createUserBusinessInfo(action) { 
    console.log(UserBusinessInfoService) 

    const userData = yield call(fire, action); 
    yield put({ 
     type: 'CREATE_USER_BUSINESS_INFO', 
     userData 
    }); 
} 

export function* createUserBusinessInfoSaga() { 
    yield takeLatest('CREATE_USER_BUSINESS_INFO_SAGA', createUserBusinessInfo); 
} 

export default function* rootSaga() { 
    yield all([ 
     helloSaga(), 
     createUserBusinessInfoSaga() 
    ]) 
} 

在信息-component.js

componentDidMount(){ 
    componentDidMount() { 
     this.props.dispatch({type: "CREATE_USER_BUSINESS_INFO_SAGA", data: {asdf : 444} }); 
    } 
} 

错误

Error

回答

0

我误解了call在终极版,传奇是call在JavaScript但它不是

的终极版 - 佐贺我们必须导入像这样

import { call ,put, takeEvery, all } from 'redux-saga/effects'