In the below I get a doc, update it, then try to use the data from the update, however undefined is logged. Why is this and how can wait to successfully fetch the new data from the doc.
db.collection("collection").doc("docid").get().then(doc =>
doc.ref.update({ message: "hello" }).then(() => console.log(doc.data().message));
)
I am using the Javascript Web version for firebase.