private async Task ExecuteHttpQuery(Func <Task <HttpResponseMessage> > httpCall) { var response = await httpCall(); switch (response.StatusCode) { case HttpStatusCode.OK: case HttpStatusCode.Created: { if (_onOk != null) { await _onOk(response); } break; } case HttpStatusCode.BadRequest: { if (_onBadRequest != null) { await _onBadRequest(response); } break; } case HttpStatusCode.NotFound: { if (_onNotFound != null) { await _onNotFound(response); } break; } case HttpStatusCode.InternalServerError: { await _jsRuntime.LaunchToast("error", "A server error occured, sorry"); break; } default: { // case HttpStatusCode.Unauthorized: // case HttpStatusCode.Forbidden: // other case , we do nothing, I'll add this case as needed break; } } }