connectionGuard method
- Duration? timeout,
checks whether a connection to the backend is possible throws NoConnectionToBackendException or SocketException if its not.
Implementation
Future connectionGuard({Duration? timeout}) async {
try {
// check if we can reach our api
await postJSON(RequestData(
'/login',
// json: {'user': User('test ', 'test').toJson()},
timeout: timeout,
)); ////logIfFailed: false));
} catch (e) {
throw NoConnectionToBackendException(
S.current!.couldntReach + " $_baseurl");
}
}