Closed gabber235 closed 5 years ago
Hi @gabber235
Is homePage
a collection or a single type of schema? If it is a single, you only need to specify the schemaKey
.
It's a single type, so I will try that.
Great, let me know how that goes for you. I will also take a look if there is a way to make the SDK code check a bit more robust for this scenario.
Hey @jperasmus,
Thanks for your quick reply today. I have changed the entryId to const entryId = schemaType === 'single' ? undefined : id
and I get undefined
which I run in app.content.get({ schemaKey: schema, entryId: entryId, populate: true })
but I still get the same error
Okay, I will deploy a newer version that will explicitly check for this use case, which should hopefully resolve this issue for you. I'll let you know as soon as it is available.
v1.0.0-alpha.8
is now available. Can you upgrade to it and test whether you're still experiencing this issue?
Now I have got this error
Error: Bucket name not specified or invalid. Specify a valid bucket name via the storageBucket option when initializing the app, or specify the bucket name explicitly when calling the getBucket() method. at FirebaseError.Error (native) at new FirebaseError (/user_code/node_modules/firebase-admin/lib/utils/error.js:42:28) at Storage.bucket (/user_code/node_modules/firebase-admin/lib/storage/storage.js:107:15) at Object.ref (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-storage/dist/cjs/cf/index.js:5218:22) at Object.<anonymous> (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-storage/dist/cjs/cf/index.js:5460:44) at step (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-storage/dist/cjs/cf/index.js:77:23) at Object.next (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-storage/dist/cjs/cf/index.js:58:53) at fulfilled (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-storage/dist/cjs/cf/index.js:48:58) at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Registration code:
const firebaseApp = admin.initializeApp(functions.config());
const app = flamelink({ firebaseApp, dbType: 'cf', precache: false });
This sounds like an issue with the Firebase admin app instance. Can you try and log out functions.config()
so we can see what you have in there? You can also try and initialize your admin app without functions.config()
The functions.config() == {}
and when I run it without I get this error
Error: A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified. Identity and Access Management (IAM) API has not been used in project 676984383187 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=676984383187 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. at GaxiosError (/user_code/node_modules/firebase-admin/node_modules/gaxios/build/src/common.js:17:9) at Gaxios.<anonymous> (/user_code/node_modules/firebase-admin/node_modules/gaxios/build/src/gaxios.js:72:27) at next (native) at fulfilled (/user_code/node_modules/firebase-admin/node_modules/gaxios/build/src/gaxios.js:16:58) at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Are you running this code on your local machine or from within Firebase Cloud Functions?
From within the firebase cloud functions on a machine from Google
Okay, this is not an issue with this Flamelink SDK anymore, but with the Firebase admin app initialization. This Flamelink SDK does not dictate how the firebaseApp
instance is created, as long as it is valid to do what is needed. In this case, the firebaseApp
instance does not have access to the storage bucket.
You will need to make sure that the way it is initialized, it includes the storageBucket
property. Something like this:
var admin = require("firebase-admin");
var serviceAccount = require("path/to/serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://<PROJECT_ID>.firebaseio.com",
storageBucket: "<BUCKET_NAME>.appspot.com"
});
Thanks for helping me, now everything works.
It's a pleasure, I'm glad it is working now!
When running a get query it doesn't work.
Imports: `import flamelink from 'flamelink/app'; import 'flamelink/content'; import 'flamelink/storage'; import 'flamelink/schemas';
const firebaseApp = admin.initializeApp(functions.config()); const app = flamelink({ firebaseApp, dbType: 'cf', precache: false });`
Query:
await app.content.get({ schemaKey: schema, entryId: id, populate: true })
the schema ishomePage
and the id is2RVNgcqGUuRMOkB5aB3j
Error:
TypeError: Cannot read property 'get' of null at isRefLike (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:7250:24) at /user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:7456:54 at step (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:80:23) at Object.next (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:61:53) at /user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:54:71 at __awaiter (/user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:50:12) at /user_code/node_modules/flamelink/node_modules/@flamelink/sdk-utils/dist/cjs/index.js:7400:75 at process._tickDomainCallback (internal/process/next_tick.js:135:7)
What is going wrong?