getSession method
get session data from server
Implementation
Future<T?> getSession() async {
try {
final url = apiBaseUrl(_config.domain, _config.authBasePath, 'session');
final response = await _config.httpClient.get(
url,
options: HttpClientOptions(
contentType: 'application/json',
cookies: await _getCookieList(attachAccessToken: true),
),
);
final body = response.body;
if (body != null && body is Map<String, dynamic> && body.isNotEmpty) {
await _cacheCSRFCookieFromHeaders(response);
return _config.sessionSerializer.fromJson(body);
}
return null;
} catch (e) {
logger?.error('getSession error', e);
return null;
}
}