从完成的功能中忽略异常

时间:2019-09-15 12:40:04

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

我正在调用第三方API,以将交易SMS发送到手机号码。通过从android客户端调用执行函数时,函数执行会给出代码200。但是日志文本显示忽略已完成函数的异常。我已经看到了许多与此有关的问题。他们都没有解决我的问题,并且与我的问题无关。

'use-strict'

var admin = require("firebase-admin");
var functions = require('firebase-functions');
var serviceAccount = require("./ServiceKey.json");
var http = require("http");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://atithikhana2.firebaseio.com/"
});


var options = {
  "method": "POST",
  "hostname": "2factor.in",
  "port": null,
  "path": "/API/V1/b5b8cefe-d3f8-11e9-ade6-0200cd936042/ADDON_SERVICES/SEND/TSMS",
  "headers": {}
};

exports.sendTNS = functions.https.onCall((data, context) => { 

 const var1 = data.var1;
 const var2 = data.var2;
 const var3 = data.var3;
 const var4 = data.var4;
 const phone_number = data.phone_number;

var req = http.request(options, function (res) {
  var chunks = [];
  res.on("data", function (chunk) {
    chunks.push(chunk);
  });
  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write(JSON.stringify({ From: 'AKINFO',
  To: 'phone_number',
  TemplateName: 'Customer_Template',
  VAR1: 'var1',
  VAR2: 'var2',
  VAR3: 'var3',
  vAR4: 'var4'}));
req.end();

  });


6:02:24.911 PM
sendTNS
Function execution started
6:02:24.911 PM
sendTNS
Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
6:02:24.917 PM
sendTNS
Function execution took 7 ms, finished with status code: 200
6:02:24.926 PM
sendTNS
Ignoring exception from a finished function

0 个答案:

没有答案