flutter dio 处理200以为的错误状态码


通过dio.post时遇到了400错误,直接到异常处理区域了,可以通过catch进行拦截

try {

  // 发送请求
  Response response = await dio.post(ossUrl, data: data);
  print(response.statusCode);
  print(response.statusMessage);
  return 'success';
} on DioError catch (e) {
  print(e.response!.statusCode);
  print(e.response!.statusMessage);
  throw(e);
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM