Logo

TODAY I LEARNED

9d2c9017388d744f99414d94f2d28aed

1 post by fabian-alcala

Set and preserve cookies on and Axios API call

I was using Axios to test an API created in Rails, trying to set up cookies for a User Authentication process. After attempting to get the information back i realize that the cookie was not persistent, due to the lack of one parameter... withCredentials: true So if you want your session to store cookies in the client side and have them available remember to pass it to the call import axios from import axios from 'axios' axios.post(API_SERVER + '/login', { email, password }, { withCredentials: true }) Otherwise the cookie would not be saved.

Learned by fabian-alcala on Jun 10, 2021

973983 adforcodereview v3 0211021 c02 021121