Hey <@498057949541826571> I am trying to call a en...
# support-questions
a
Hey @rp I am trying to call a endpoint at two different places one at the click of a button and other when the page is refreshed in the first case I am able to see the cookies being passed in the request headers but in the case where I refresh the page the api returns a 440 and the cookies are missing
r
hey @abhisheksinghkapoor which SDKs are you using and which version?
a
Supertoken-website v4.4.1
r
backend?
a
At the backend we have supertokens/supertokens-laravel: ~1.5.0
r
when you say refresh the page and the api returns a 440, what exactly does that mean? Can you be more specific about which page. which API?
a
So basically we have a api that returns the list of user associated to a specific account to the frontend which we render, the api is called in the middleware which then fetches list of users, now when we call the api on page refresh it returns Unauthorised, and the cookies are deleted, also when I checked in the request headers no cookies were being sent
Now when I call the same api with click of a button I can see the cookie are being sent and the api is able to authorize and returns the required list of users and I can see that cookies are being sent in request headers
r
"the api on page refresh it returns Unauthorised" -> what does this mean? The browser is calling the API? Or your JS code is calling the API?
a
Yes we are calling it from the JS code, "the api on page refresh it returns Unauthorised" I meant we are unable to send the cookies to the backend for verification
r
make sure that the frontend SDK is initialised before any API call is being made
a
Hey I was debugging for this, in the node modules axios.js when I am refreshing as there was no file being passed through function 'interceptorFunctionRequestFulfilled'
r
right
a
So this means the SDK isn't initialised when the call is made but in the api function I am checking if the SuperTokensRequest.doesSessionExist() returns true and it returns true. Can the following function return true when sdk is not initialised
r
it shouldn't. It should throw an error
the SDK may have been initialised, but if you are using axios, then you need to rememeber to add the axios interceptor.
a
I am using the "SuperTokensRequest.makeSuper($axios);" in the JS file for supertoken, also the supertoken gets initialised after the api call is made post refresh but the session Check returns true
Also is there a way to force initialisation before the api call
r
no way to force initialisation before API call. Just add the init call to the global scope of your app
a
Ok thank you