0

I am trying to login to a website using (for now) axios post request. In python using request, I can instantiate a session object and it will keep me logged in after I've posted the login data to the website. I am guessing this has to do with persistent cookies.

I want this same functionality in Javascript, and have tried to find solutions with Axios. I can't seem to find anything relevant on Google or on Stackoverflow. Is there any way you can persist cookies in Axios, or is there any other npm package that functions similar to Python's requests session?

DanDev
  • 39
  • 1
  • 1
  • 5
  • https://stackoverflow.com/questions/52549079/does-axios-support-set-cookie-is-it-possible-to-authenticate-through-axios-http perhaps – CertainPerformance Feb 02 '21 at 13:44
  • How is that relevant at all? – DanDev Feb 02 '21 at 13:47
  • Oops, pasted the wrong link, check again – CertainPerformance Feb 02 '21 at 13:47
  • How does authentication work for the website you are targeting? Are they using something like an api key for each request? Do they store something similar in the cookies sent within the request? – Countour-Integral Feb 02 '21 at 13:48
  • I'm sure they store authentication in cookies. But once again, requests session used to handle all that for me when i used python. – DanDev Feb 02 '21 at 13:52
  • @DanDev Instead of guessing, you could just do some reverse-engineering by looking at browser requests and cookies (and all relevant things like localStorage etc) and then do exactly what the browser does for authentication. – Countour-Integral Feb 02 '21 at 13:55
  • I just said I'm sure they use cookies lol. – DanDev Feb 02 '21 at 13:56
  • Found what I was looking for. Superagent persists the cookies and allows me to stay logged in. https://visionmedia.github.io/superagent/ – DanDev Feb 02 '21 at 14:54

0 Answers0