Refactor cookie handling in Index and update API call in Schedule for improved error logging and response handling
This commit is contained in:
@@ -56,7 +56,19 @@ export default function Index() {
|
||||
}
|
||||
);
|
||||
|
||||
const cookie = response.headers['set-cookie']?.join('; ') || '';
|
||||
const cookieArray = response.headers['set-cookie'] as string | string[] | undefined;
|
||||
let cookie = '';
|
||||
if (Array.isArray(cookieArray)) {
|
||||
const lastAuth = cookieArray.reverse().find(c => c.startsWith('.ASPXAUTH='));
|
||||
if (lastAuth) {
|
||||
cookie = lastAuth.split(';')[0];
|
||||
}
|
||||
} else if (typeof cookieArray === 'string' && cookieArray.startsWith('.ASPXAUTH=')) {
|
||||
cookie = cookieArray.split(';')[0];
|
||||
}
|
||||
|
||||
console.log('Set-Cookie:', cookieArray);
|
||||
console.log('cookie:', cookie);
|
||||
|
||||
const userId = response.data.Data.UserID;
|
||||
const fullName = response.data.Data.FullName;
|
||||
|
||||
Reference in New Issue
Block a user