Flamelink CMS retrive data pure js

107 Views Asked by At

i am already setup firebase and flamelink how i get data to manipulate from global i try this but it not work:

        var obj ={}
        app.content.get({schemaKey: 'berita'})
            .then((data) => {
                obj = data
                console.log("data" , data)
                console.log("object" , obj)
            })
            console.log("outsite", obj)

why output for obj different? enter image description here

1

There are 1 best solutions below

0
telliks On

app.content.get() returns a Promise, so your console.log('outsite, obj) line runs before the query Promise is resolved.

You either need to work with the response data inside your then method or use async-await like this (from inside an async function):

var obj = await app.content.get({schemaKey: 'berita'})
console.log("outsite", obj)