node.js firebase返回则不是函数

时间:2018-05-31 05:58:16

标签: node.js firebase google-cloud-functions

我在node.js中有这个Request方法,它给我一个键/值异步。我需要全局获取此值,但它将在范围之外被定义。要做到这一点,我试图实施"然后"在功能,但它回来了我

TypeError: request(...).then is not a function
at Object.<anonymous> (E:\FirebaseNotif\group.js:26:4)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:719:10)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)

我的要求是......

 request(options, function (error, response, body) {
 console.log(body);
 key = body.notification_key;

 return key;

 }).then(result =>{
 console.log('my key is : ' + key); 
 });

0 个答案:

没有答案