2

我正在尝试创建我的第一个 Google Home Action,就像我的 Amazon Alexa Skill 一样。此操作的工作方式是,您执行一个意图,并在我的代码中调用一个函数。调用该函数时,它会向外部 API 发送 GET 以提取一些数据。

现在,当我在本地使用:firebase serve --only functionsngrok. 这些将允许我在 API.AI 上测试该功能并且它工作正常。

但是当我决定使用: 将其部署到firebase时firebase deploy --only functions,它根本不起作用并抛出此错误:

error: { RequestError: Error: getaddrinfo EAI_AGAIN newsapi.org:443
    at new RequestError (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/errors.js:14:15)
    at Request.plumbing.callback (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:87:29)
    at Request.RP$callback [as _callback] (/user_code/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at self.callback (/user_code/node_modules/request/request.js:188:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestError (/user_code/node_modules/request/request.js:884:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at connectErrorNT (net.js:1020:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
  name: 'RequestError',
  message: 'Error: getaddrinfo EAI_AGAIN newsapi.org:443',
  cause: 
   { Error: getaddrinfo EAI_AGAIN newsapi.org:443
       at Object.exports._errnoException (util.js:1026:11)
       at errnoException (dns.js:33:15)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
     code: 'EAI_AGAIN',
     errno: 'EAI_AGAIN',
     syscall: 'getaddrinfo',
     hostname: 'newsapi.org',
     host: 'newsapi.org',
     port: 443 },
  error: 
   { Error: getaddrinfo EAI_AGAIN newsapi.org:443
       at Object.exports._errnoException (util.js:1026:11)
       at errnoException (dns.js:33:15)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
     code: 'EAI_AGAIN',
     errno: 'EAI_AGAIN',
     syscall: 'getaddrinfo',
     hostname: 'newsapi.org',
     host: 'newsapi.org',
     port: 443 },
  options: 
   { uri: 'https://newsapi.org/v1/articles?source=hacker-news&sortBy=top&apiKey=8b87b4978b22493cadeb351cce01d52a',
     headers: { 'User-Agent': 'Request-Promise' },
     family: 4,
     json: true,
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: undefined }

我似乎找不到任何不起作用的原因,因为我可以在本地对其进行测试并通过点击请求中使用的相同 URL 来获取数据。在此示例中,我使用request-promise来完成请求,但我也使用了库:gotrequesthttps.

我该如何克服这个问题?

4

1 回答 1

5

我发现的唯一一件事可能是我没有使用付费 Firebase 计划

于 2017-07-07T13:17:39.533 回答