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