未捕获的错误:Firebase.update失败:第一个参数在属性&product; qua.quantity'中包含NaN。

时间:2017-04-14 13:03:11

标签: javascript reactjs firebase-realtime-database react-redux

未捕获错误:Firebase.update失败:第一个参数在属性&product; .quantity'

中包含NaN

当我尝试使用此代码时,它会出现错误"未捕获的错误:Firebase.update失败:第一个参数在属性&product; .quantity'"

中包含NaN
      import Actions from './actionTypes'
import * as DB from '../../firebase/database'

export function saleAction(storeData){
     console.log('222222222222',storeData)
    return dispatch =>{

        dispatch(SaleAction());
        return DB.database.ref('/sale').push(storeData).then((data)=>{
            return DB.database.ref('/products/').once('value',(snap)=>{
                var oldQty  = parseInt(snap.val().quantity);
                console.log('quantityyyyyyyyyyy',oldQty)
                var newQty  = parseInt(oldQty - parseInt(storeData.quantity));
                return DB.database.ref('/products').set(newQty,(done)=>{
                    alert('successfuly')
                    dispatch( SaleActionSuccess(data))
                })
            })

        })
        .catch((error)=>{
            dispatch((SaleActionFailed(error)))
            alert('failed')
        })


    }
}

export function SaleAction(){
    return{
        type:Actions.ADDSALEREQUEST
    }
}

export function SaleActionSuccess(data){
    return{
        type: Actions.ADDSALEREQUESTSUCCESS,
        data
    }
}
export function SaleActionFailed(){
    return{
        type: Actions.ADDSALEREQUESTFAILED
    }
}
export default saleAction;

0 个答案:

没有答案