``` async function doesSessionExist() { if (aw...
# support-questions
d
Copy code
async function doesSessionExist() {
    if (await SuperTokens.doesSessionExist()) {
      // user is logged in
      console.log("there is a session");
    } else {
      // user has not logged in yet
    }
  }
this returns error in react native
r
hey @dhatGuy how are you importing supertokens?
d
import SuperTokens from 'supertokens-react-native';
r
have you called supertokens.init?
perhaps @nkshah2 can help here too
n
Hey @dhatGuy can you post the code for where you are calling SuperTokens.init?
d
Copy code
import SuperTokens from "supertokens-react-native";

const apiDomain = "http://192.168.43.75:7000"; // TODO: change url to your own IP address

SuperTokens.init({
  apiDomain,
  apiBasePath: "/api/auth",
});
am I meant to export it?
n
Nope, as long as that piece of code is running before you access any of the functions it should work
Can you add a log above the init call and another one before using doesSessionExist and see what order the code is running in?
d
I think I've found the error. I should have the code above in App.js
n
Yeah it should be in a place that always runs before the rest of your app
Either App.js or index.js works
index for the app I mean
d
im getting an error, "Please, provide a valid domain name"
n
Strange, the value you use does work for me
d
it works now. I had to restart the server
thanks
n
Ah, happy to help
d
please, it keeps saying I don't have any session
even after logging in
r
@dhatGuy what's the backend config?
d
it's a bit large coz I have custom config
r
just the appInfo part and session.init part
d
Copy code
appInfo: {
    appName: "nsm",
    apiDomain: "http://localhost:7000",
    websiteDomain: "http://localhost:3000",
    apiBasePath: "/api/auth",
    websiteBasePath: "/api/auth",
  }
r
you need to make sure that you use the same apiDomain value on frontend and backend
d
Session.init({})
in RN, I cant use localhost
i have to use the network ip address
r
so you need to give that to the apiDOmain on the backend as well.
ok i think the issue could be something else
are you using axios?
if yes, you need to make sure that you had added the supertokens interceptor to the axios instance
d
I have. The issue was me using a wrong ip address. im receiving a response that there is session now
thank you
r
Ok great!
2 Views