A
A
AlexBelan2021-05-12 23:51:04
Android
AlexBelan, 2021-05-12 23:51:04

Returns undefined RealmJS on React Native?

Hello. Now I'm developing an Android application, using React Native, using Realm for data storage.

For convenience, I created a class that should work with a certain data type in Realm, and there I created a method to get all the data from the Database, here it is:

getFiles = () => {
    Realm.open({schema: [this.file]})
    .then( realm => {
        let file = realm.objects('file')
        realm.close();
        return file
    }).catch(error => {
        console.log(error);
    })
}


Then I call this method and put the value in a variable:
let filesRealm = RealmFile.files;
console.log(filesRealm)


But when I print the value of the variable to the console, it prints undefined. Tell me how to fix this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question