getDio static method

Dio getDio(
  1. bool checkToken
)

Implementation

static Dio getDio(bool checkToken) {
  Dio dio = getDefaultDio();
  if (checkToken) {
    dio.interceptors.add(InterceptorsWrapper(onRequest: (options, handler) {
      print('send request:path:${options.path},baseURL:${options.baseUrl}');
      if (_ut.isEmpty) {
        updateToken(dio).then((value) async {
          _ut = value.data['ut'];
          options.headers['Cookie'] = 'ut=$_ut';
          handler.next(options);
        });
      } else {
        options.headers['Cookie'] = 'ut=$_ut';
        handler.next(options);
      }
    }, onError: (e, handler) {

    }));
  }
  return dio;
}