res_interceptor.dart 480 B

123456789101112131415161718192021222324252627282930
  1. import 'dart:async';
  2. import 'package:get/get.dart';
  3. import 'package:get/get_connect/http/src/request/request.dart';
  4. //获取到相应的响应拦截
  5. FutureOr<dynamic> responseInterceptor(Request request, Response response) async {
  6. if (response.statusCode != 200) {
  7. handleErrorStatus(response);
  8. return;
  9. }
  10. return response;
  11. }
  12. void handleErrorStatus(Response response) {
  13. switch (response.statusCode) {
  14. case 400:
  15. break;
  16. default:
  17. }
  18. return;
  19. }