Problems with mongo db realm

For the past 6 months i’ve being trying to implement Realm on my react native app with typescript. I followed tutorials and read the documentation multiple times, i even cloned there original tutorial to try it out and to my surprise the app didn’t work, it throw addItemTask is not a function.

I’ve tried stack-overflow for help and no one came to the rescue. I tried github yet no one help me there. I’ve given up on trying to integrate my app using realm or mongo technologies as the community and support is scares.

Now i don’t know what to do as my app requires an offline database and sync capabilities.

if there’s anyone out the who can help understand realm with react native please help me, i’m out of options and my anxiety levels have went up 100%.

Sure, we’d be happy to help - what is your problem/error message that you’re seeing and what are you trying to do?

1 Like

I’m trying to add/save inventory items on atlas whenever the user has an internet connection, however if the user is offline i want the data to be stored on the phone and synced to realm whenever the user goes online.

i created my getRealmApp.ts as follows:
Screenshot 2021-02-01 at 18.53.59

and wrote my schema file as follows:
Screenshot 2021-02-01 at 19.04.18

and in my component i imported the realm app like this:

const app = getRealmApp()

and the fuction below was to test the login and to try and save those items on the database:

when i run the save function i get:
ERROR: Connection[1]: Websocket: Expected HTTP response 101 Switching Protocols, but received: HTTP/1.1 401 Unauthorized cache-control: no-cache, no-store, must-revalidate connection: close content-length: 190 content-type: application/json date: Mon, 01 Feb 2021 17:06:02 GMT server: envoy vary: Origin x-envoy-max-retries: 0 x-frame-options: DENY

and the other error is

Error opening realm: {}

and now when i anonymously i can not find the user created

please feel free to let me know if i’m implement things wrongfully

Interesting… The code you’ve posted seems correct - can you check if there are any error logs on the server? Those might shed more light as to why the user is considered unauthorized. Additionally - do you have any access rules defined on the server? It could be that the user doesn’t have permission to access that partition.

1 Like

I’ve enable the this rules for sync

I was trying to see what was happening when i opened realm, I got this:
Error opening realm: {}

and
Connection[1]: Session[1]: client_reset_config = false, Realm exists = true, async open = false, client reset = false

and finally:
ERROR: Connection[1]: Websocket: Expected HTTP response 101 Switching Protocols, but received: HTTP/1.1 401 Unauthorized cache-control: no-cache, no-store, must-revalidate connection: close content-length: 190 content-type: application/json date: Wed, 03 Feb 2021 21:59:57 GMT server: envoy vary: Origin x-envoy-max-retries: 0 x-frame-options: DENY Connection[1]: Connection closed due to error

and all of this is coming from the onSaveItem function:
Screenshot 2021-02-04 at 00.06.02