firebase set failed first argument contains undefined in property

孤人 提交于 2020-01-24 13:08:15

问题


When I create an event, I do this:

export const eventCreate = ({ title, time, location }) => {
  const newPostKey = firebase.database().ref('/events').push().key;
  const update = {};

  const postDetails = {
    eventId: newPostKey,
    title,
    ...
    goingNumber: 1,
    ...
  };

  update[`/events/${newPostKey}`] = postDetails;

  return (dispatch) => {
    firebase.database().ref()
      .update(update)
      .then(() => {
        dispatch({ type: EVENT_CREATE });
      })
      .then(() => newPostKey);
  };
};

in the database:

later when I try to update the goingNumber:

export const eventSave = ({ goingNumber, eventId }) => {    
  return (dispatch) => {
    firebase.database().ref(`/events/${eventId}`)
      .set({ goingNumber })
      .then(() => {
        dispatch({ type: EVENT_SAVE_SUCCESS });
      });
  };
};

I get this error saying:


回答1:


You're not passing in a value for goingNumber. My guess is that you're looking for

firebase.database().ref(`/events/${eventId}`)
        .child('goingNumber').set(goingNumber )


来源:https://stackoverflow.com/questions/44246602/firebase-set-failed-first-argument-contains-undefined-in-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!