getRequestHeaders method
Get headers for standard API request
If AuthenticationService says the user is authenticated the token will also be added to the headers.
Implementation
Map<String, String> getRequestHeaders() {
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
// If the user is logged in add their token to the request headers
final AuthenticationService _authService = locator<AuthenticationService>();
if (_authService.isAuthenticated) {
// We know a token must exist as the user is authenticated
// headers['token'] = _authService.token!;
headers['Authorization'] = "JWT ${_authService.token!}";
}
return headers;
}