2017-07-07 69 views
0

我試圖建立我的第一個谷歌主頁的行動與我的亞馬遜Alexa的技能相同functinality。這一行動的工作方式是,你執行的意圖,並調用在我的代碼的功能。當函數被調用時,它發送一個GET到一個外部API來提取一些數據。部署火力地堡功能無法執行HTTP GET外部API?

現在,當我運行這個本地使用:firebase serve --only functionsngrok。這些將允許我測試API.AI的功能,並且工作正常。

但是,當我決定要部署此使用到火力地堡: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

我該如何克服這個問題?

+0

您需要付費計劃向外部API發出請求。見https://stackoverflow.com/questions/42774807/firebase-functions-getaddrinfo-enotfound-api-sandbox-paypal-com –

回答

1

我發現的唯一情況可能是我沒有使用付費的Firebase計劃