I'm following the example from the github repository to short a link url
https://github.com/firebase/functions-samples/tree/Node-8/url-shortener
The error is giving is the following
12:49:56.472 a. m. shortenUrl Function execution took 509 ms, finished with status: 'error' 12:49:56.464 a. m. shortenUrl RequestError: Error: getaddrinfo EAI_AGAIN api-ssl.bitly.com:443 at new RequestError (/srv/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/srv/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/srv/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/srv/node_modules/request/request.js:185:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (/srv/node_modules/request/request.js:881:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketErrorListener (_http_client.js:387:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
I'm really new at functions but I did follow all the steps from the documentation there.
here is my index.js inside my functions folder
const functions = require('firebase-functions');
const BitlyClient = require('bitly');
// TODO: Make sure to set the bitly.access_token cloud functions config using the CLI.
const bitly = BitlyClient(functions.config().bitly.access_token);
// Shorten URL written to /links/{linkID}.
exports.shortenUrl = functions.database.ref('/links/{linkID}').onCreate(async (snap) => {
const originalUrl = snap.val();
const response = await bitly.shorten(originalUrl);
return snap.ref.set({
original: originalUrl,
short: response.data.url,
})
});
and my package.json in order to compile the the neccesary for bitly
{
"name": "url-shortener-functions",
"description": "URL Shortener Firebase Functions sample",
"dependencies": {
"bitly": "^5.1.7",
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.5"
},
"devDependencies": {
"eslint": "^4.13.1",
"eslint-plugin-promise": "^3.6.0"
},
"scripts": {
"lint": "./node_modules/.bin/eslint --max-warnings=0 .",
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"private": true
}
I also did npm -install bitly
inside my functions folder but still throwing that error
Also I added my link inside my database as the documentation states
/functions-project-12345
/links
link-123456: "https://my.super.long-link.com/api/user/profile/-jEHitne10395-k3593085"
Any clue ? thanks