Я приобрел план пламени для облачной функции. Я развертываю свой веб-крюк, используя поток диалога, все еще получая ту же ошибку:
Ошибка: getaddrinfo ENOTFOUND jsonplaceholder.typicode.com/ jsonplaceholder.typicode.com/: 8080
в errnoException (dns.js: 28: 10)
в GetAddrInfoReqWrap.onlookup [как завершено] (dns.js: 76: 26)
'use strict';
var https = require ('https');
const functions = require('firebase-functions');
const DialogFlowApp = require('actions-on-google').DialogFlowApp;
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request,
response) => {
let action = request.body.queryResult.action;
var chat = "here is a sample response: trump sucks";
response.setHeader('Content-Type','application/json');
if (action!= 'input.getStockPrice'){
console.log('Inside input function');
response.send(buildChatResponse("I'm sorry, I don't know this"));
return;
}
getStockPrice (response);
});
function getStockPrice (CloudFnResponse) {
var pathString = "users/2";
var request = https.get({
host: "jsonplaceholder.typicode.com/",
path: pathString,
}, function (response) {
var json = "";
response.on('data', function(chunk) {
console.log("received JSON response: " + chunk);
json += chunk;
});
response.on('end', function(){
var jsonData = JSON.parse(json);
console.log("1");
var stockPrice = jsonData.name
console.log ("the stock price received is:" + stockPrice);
CloudFnResponse.send(buildChatResponse(stockPrice ));
});
});
}
function buildChatResponse(chat) {
return JSON.stringify({"fulfillmentText": chat});
}