为什么在继续操作之前不等(Firestore get命令以欢迎方式)

时间:2019-06-02 09:56:59

标签: javascript google-cloud-firestore

我的欢迎意图中包含此代码,我认为诺言正确,不是等待使用.then命令吗?但是,每次我启动该应用程序时,它都会继续执行语音命令,此时问题1是未定义的,在我运行了2-3次后,它给出了足够的时间,然后它被设置了,但是我认为已经设置好了,等待诺言。这样做吗?

var cityRef = db.collection('text').doc('currentquestion2');
var getDoc = cityRef.get().then(doc => {
if (!doc.exists) {
console.log('No such document!');
} else {

 question1 = doc.data().n111;
 question1yes = doc.data().n222;
 question1no = doc.data().n333;

//variables set based on data



 }


 })

 .catch(err => {
 console.log('Error getting document', err);
 })


const ssml =
'<speak>' + '<audio 
src="https://steven96813.000webhostapp.com/audio/welcome.mp3">Welcome 
back</audio>' + 

question1 +
'</speak>';

// first口头命令使用var问题1,但是没有设置第一次。

conv.ask(ssml);

0 个答案:

没有答案