I set up a project to return a value to app.js without it having to process the promise. This code returns undefined when I run it. Any Tips?
export.js `
const admin = require('firebase-admin')
const db = admin.firestore();
const ref = db.collection('Things')
async function getNameV(ting) {
return await ref.get().then(doc => {
doc.forEach(documentSnapshot => {
var data = documentSnapshot.data()
if (ting == data.name || ting == data.id) {
return data.name
}
})
})
};
module.exports.getName = function(ting) {
getNameV(ting).then(value =>{
console.log(value)
return value;
})
};
app.js
const exp = require('./export.js')
var name = await exp.getName('foo')
console.log(name)
.thenwhen you haveasync/await?