0

I have started a new project and having a push error in my function. I am not sure where the error is coming from

exports.ObserveStatus = functions.database.ref("/patients/{patient_id}/status/current").onWrite((event) => {
  const snap = event.data;
  const patient_id =  event.params.patient_id;
  if (snap.exists() && snap.child("status_id").changed()) {
    let p_timer = {
      status_id: snap.previous.child("status_id"),
      started: snap.previous.child("started"),
      ended: admin.database.ServerValue.TIMESTAMP
    };
    return admin.database().ref(`/patients/${patient_id}/status/previous`).push(p_timer);
  }

This is the error I am getting in the console:

Error: Firebase.push failed: first argument contains a function in property 'patients.-KpZ9wyqIrlTafE1sIHL.status.previous.status_id.app.firebaseInternals_.firebase_.credential.cert' with contents: function (serviceAccountPathOrObject) { var stringifiedServiceAccount = JSON.stringify(serviceAccountPathOrObject); if (!(stringifiedServiceAccount in globalCertCreds)) { globalCertCreds[stringifiedServiceAccount] = new credential_1.CertCredential(serviceAccountPathOrObject); } return globalCertCreds[stringifiedServiceAccount]; } at Error (native)

1 Answer 1

2

It is missing when getting references snap.previous.child

.val()

It should be

snap.previous.child("started").val()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.