2017-05-14 97 views
2

我的问题是使用API​​以及Firebase函数,所讨论的API是Coinbase,我使用带有节点的API,如果我使用节点命令在终端中测试它但是当我将它与Firebase函数结合使用时根本不起作用,我一直在尝试解决这个问题近一个星期。Firebase和第三方api的云端函数

的代码如下>

var functions = require('firebase-functions'); 


    var Client = require('coinbase').Client; 
    var client = new Client({ 
     "apiKey": "xxxxxxxxxxxx", 
     "apiSecret": "xxxxxxxxxxxxxxxxxxxxxxx" 
    });  


exports.helloWorld = functions.https.onRequest((request, response) => { 



    this.client.getAccounts({}, function(err, accounts) { 

     if(accounts){ 

      response.send(accounts); 
     }else{ 
      response.send(err); 

     } 

    }); 
}); 

错误:https://us-central1-investimentos-b7406.cloudfunctions.net/helloWorld

的Coinbase API:https://developers.coinbase.com/docs/wallet/guides/bitcoin-wallet

+2

您是否使用免费的[Firebase Spark](https://firebase.google.com/pricing/)计划?它只限制对Google服务的出站联网请求。 –

+0

是的,我使用Spark,所以要求Google退出需要升级? –

+1

是的,你需要升级。 –

回答

4

有一个在docs警告:

Firebase projects on the Spark plan can make only outbound requests to Google APIs. Requests to third-party APIs fail with an error. For more information about upgrading your project, see Pricing .

所以你将需要升级到付费p lan使用外部API。