In the following javascript code snippet (written for nodejs), the createDoc function returns a promise. Upon fulfillment of the promise, the handler passed to .then is invoked. The question is that how can I make .then return doc? According to the documentation, .then returns a promise but I'm really looking for it to return doc.
let p = createDoc(title).then(function (doc) {return doc;});
//p is a promise, and not doc
console.log(p);
What is the proper way to access the value passed to the fulfillment handler (doc in this case) outside the .then?