getDio function
Dio
getDio()
Implementation
Dio getDio() {
dio.interceptors.add(
InterceptorsWrapper(
onRequest: (RequestOptions options, RequestInterceptorHandler handler) async {
// Do something before request is sent.
// If you want to resolve the request with custom data,
// you can resolve a `Response` using `handler.resolve(response)`.
// If you want to reject the request with a error message,
// you can reject with a `DioError` using `handler.reject(dioError)`.
return handler.next(options);
},
onResponse: (Response<dynamic> response, ResponseInterceptorHandler handler) {
return handler.next(response);
},
onError: (DioError e, ErrorInterceptorHandler handler) {
return handler.next(e);
},
),
);
return dio;
}