Firebase网络挂钩



我已经购买了云功能的火焰计划。我正在使用对话流部署我的webhook,但仍然收到相同的错误:

错误:getaddrinfo ENOTFOUND jsonplaceholder.tymode.com/jsonplaceholder.typicode.com/:8080

在errnoException(dns.js:28:10(

在GetAddrInfoReqWrap.onlookup[作为oncomplete](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});
}

使用完整URL,而不是部分URL。你错过了计划部分。可能是https:

host: "https://jsonplaceholder.typicode.com/",

相关内容

  • 没有找到相关文章

最新更新