Open shivam-k opened 5 years ago
Have you got any solutions?
@NaveenSubburaj, Unfortunately, no!
@shivam-k Solved the issue finally. Get the config variable from the firebase console directly and pass it on to your initialize function. It seems that database and google actions projects were not connected well. It would look something like this.
var config = { apiKey: "xxxxxxxx", authDomain: "xxxxxxx", databaseURL: "xxxxxx", projectId: "xxxxx", storageBucket: "xxxxx", messagingSenderId: "xxxxxx" };
const admin = require('firebase-admin'); admin.initializeApp(config);
Any solved issue or not?
any luck?
Anyone solved this issue?
I've fixed this issue by creating an this environment var:
FIREBASE_CONFIG="{\"databaseURL\":\"https://{gcloud-project-id}.firebaseio.com\",\"storageBucket\":\"{gcloud-project-id}.appspot.com\",\"projectId\":\"{gcloud-project-id}\"}"
then
import * as admin from 'firebase-admin';
// start your app
admin.initializeApp(JSON.parse(FIREBASE_CONFIG));
// lots of code...
Naturally, replace {gcloud-project-id} with your actually project id.
FIREBASE_CONFIG="{\"databaseURL\":\"https://{gcloud-project-id}.firebaseio.com\",\"storageBucket\":\"{gcloud-project-id}.appspot.com\",\"projectId\":\"{gcloud-project-id}\"}"
my project id is "test-v1" is this how I do it.
FIREBASE_CONFIG="{\"databaseURL\":\"https://test-v1.firebaseio.com\",\"storageBucket\":\"test-v1.appspot.com\",\"projectId\":\"test-v1\"}"
Could you tell me where I can put that? Do I just past it inside the index.js file.
I am using Google cloud platform with firestore. I do everything in the browser. I don't have any SDK's installed.
I am creating a bot on Dialogflow, and I am using Dialogflow-fulfillment for dynamic response and Firebase Real-time Database as a database.
What I am trying to do here is, suppose a hospital which provides certain facility has several centres(locations) in the country. Now when the user requests for such hospital, the bot should be able to output him the location of the nearby hospital. I do have the list of all such hospitals (with unique latitude & longitude) in Firebase Real-Time Database. My approach to this is that I will get the precise location of the user and compare it with locations available in the database to find the nearest hospital. Now I wish to output about this hospital to the user with extra information (like the address of the hospital, contact, website, opening hours, etc.) with the use of Google Place API (I have a billing account and API Key).
Although I am able to get the precise location of the user with longitude and latitude, I am facing some problems in dealing with Google Place API. Here are some errors that I am getting in "Firebase Logs":
Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail
and
Error: Can't set headers after they are sent. at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:356:11) at ServerResponse.header (/var/tmp/worker/node_modules/express/lib/response.js:767:10) at ServerResponse.send (/var/tmp/worker/node_modules/express/lib/response.js:170:12) at ServerResponse.json (/var/tmp/worker/node_modules/express/lib/response.js:267:15) at callPlaceAPI.then.catch (/user_code/index.js:480:34) at process._tickDomainCallback (internal/process/next_tick.js:135:7)
I tried changing many different ways of initialising firebase-admin, but the above error remains the same. I did this:
and even this:
My
package.json
is:Would you help me understand the problem? My index.js contains more than 600 lines of code, still, I am providing link to it for your consideration. Here: https://gist.github.com/shivam-k/49cfd05b36eb52d219f99b20cf285f03
Some important thing before you start reading the code:
Any suggestion on how to make a call to Place API and parse results from would be highly appreciated. Your any advice would be very encouraging to me.