0

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

rifo pangemanan
  • 344
  • 1
  • 3
  • 15

1 Answers1

0

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)
telliks
  • 1,216
  • 10
  • 13