javascript - Uncaught Error: Firebase.update failed: First argument contains NaN in property 'products.quantity' -
uncaught error: firebase.update failed: first argument contains nan in property 'products.quantity'
when tried code gives error "uncaught error: firebase.update failed: first argument contains nan in property 'products.quantity'"
import actions './actiontypes' import * db '../../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;
Comments
Post a Comment