mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
Semi-implemented getting spaces feature
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
|
||||
class HTTPInterceptor extends InterceptorsWrapper {
|
||||
// @override
|
||||
@ -7,36 +8,38 @@ class HTTPInterceptor extends InterceptorsWrapper {
|
||||
// return handler.next(response);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void onRequest(RequestOptions options,
|
||||
// RequestInterceptorHandler handler) async {
|
||||
// // TODO: Implement logic for adding headers to requests.
|
||||
// // This method is called before a request is sent.
|
||||
// super.onRequest(options, handler);
|
||||
// }
|
||||
//
|
||||
// @override
|
||||
// void onError(DioException err, ErrorInterceptorHandler handler) async {
|
||||
// // TODO: Implement error handling logic.
|
||||
// // This method is called when an error occurs during a request.
|
||||
// super.onError(err, handler);
|
||||
// }
|
||||
//
|
||||
// /// Validates the response and returns true if it is successful (status code 2xx).
|
||||
// Future<bool> validateResponse(Response response) async {
|
||||
// if (response.statusCode != null) {
|
||||
// if (response.statusCode! >= 200 && response.statusCode! < 300) {
|
||||
// // If the response status code is within the successful range (2xx),
|
||||
// // return true indicating a successful response.
|
||||
// return true;
|
||||
// } else {
|
||||
// // If the response status code is not within the successful range (2xx),
|
||||
// // return false indicating an unsuccessful response.
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// // If the response status code is null, return false indicating an unsuccessful response.
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
@override
|
||||
void onRequest(
|
||||
RequestOptions options, RequestInterceptorHandler handler) async {
|
||||
//pass the token from the flutter secure storage to the request header
|
||||
|
||||
options.headers['Authorization'] = 'Bearer ${AuthCubit.token.accessToken}';
|
||||
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
//
|
||||
// @override
|
||||
// void onError(DioException err, ErrorInterceptorHandler handler) async {
|
||||
// // TODO: Implement error handling logic.
|
||||
// // This method is called when an error occurs during a request.
|
||||
// super.onError(err, handler);
|
||||
// }
|
||||
//
|
||||
// /// Validates the response and returns true if it is successful (status code 2xx).
|
||||
// Future<bool> validateResponse(Response response) async {
|
||||
// if (response.statusCode != null) {
|
||||
// if (response.statusCode! >= 200 && response.statusCode! < 300) {
|
||||
// // If the response status code is within the successful range (2xx),
|
||||
// // return true indicating a successful response.
|
||||
// return true;
|
||||
// } else {
|
||||
// // If the response status code is not within the successful range (2xx),
|
||||
// // return false indicating an unsuccessful response.
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// // If the response status code is null, return false indicating an unsuccessful response.
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Reference in New Issue
Block a user