axios : How exactly to preserve session after successful authorization and send with subsequent request
In this test case am sending an axios post request with userId and password to ExpressJS server running with passportjs local. Server respond with status code 200, and send appropriate header with set-cookie. I need subsequent request to be treated as authorized request, for that tried following options, but none seems to be working. It getting rejected with status code 401. First call with userid and password, responded with status 200 const userDoc = { userId: 'test-user-1', userName: 'Test User 1', emailId: 'test.user.1@abc.xom', password: 'test-password' } ; let resp resp = await axios({method : 'post', url : 'http://localhost:4040/auth/local', data : {userId: userDoc.userId, password: userDoc.password },withCredentials: true }) following options are used to send next request send cookies received as part of 1st request const headers = { headers : {Cookie: resp.headers['set-cookie'][0] } }; send ...