HI, I am developing a phoenix front end application where i am required to send ajax request to phoenix api but i am finding it difficult- how to send the request along with the auth token - As the api endpoint is protected by auth plug.
so what is the best way to send ajax request when i am logged in to the browser.
I tried writing a custom plug which will first check if the request is coming via api -> then i am parsing from conn
if the request is from browser then i am fetching the user from sesssion and validating it
but the issue is it is showing invalid token
so i tried to add the same jwt token in the session, but the response is same as it is showing invalid token.
I am using browser auth method as per phx_gen_auth
and using methods like that one.
How should i really go about it to successfully send a ajax request from browser to an api endpoint that needs jwt to verify in normal usecases.