http put did not send any response in flutter

Viewed 33

Hey I have this app where I can update status, and I use http.put method, but it takes forever to response. I got this error

error

1

And here is the code for http.put

Future<void> mapEventToState(
  Emitter<ReportStatusState> emit, ReportStatusEvent event) async {
emit(ReportStatusLoading());
ReportStatusPut statusPut = event.statusPutBody;
// ReportStatusModel model =
//     await apiAuthRepository.updateReportStatus(statusPut, event.id);
ReportStatusModel model = await updateReportStatus({'biaya': '0', 'status': 'SELESAI'}, event.id);
print(model);
if (!model.success) {
  emit(ReportStatusFailure(model.message));
}
print(model.code);
emit(ReportStatusSuccess());
}}

Future<ReportStatusModel> updateReportStatus(
 Map data, String id) async {
 final SharedPreferencesManager sharedPreferencesManager = 
 locator<SharedPreferencesManager>();
 String? token = 
  sharedPreferencesManager.getString(SharedPreferencesManager.keyAccessToken);
 try {
final response = await http.put(
    Uri.parse('https://api.komplekku.com/officer/api/report/v1/$id'),
    body: json.encode(data),
headers: {'Authorization': 'Bearer $token'});
return ReportStatusModel.fromJson(json.decode(response.body));
} catch (e) {
throw Exception(e);
}
}

There is nothing wrong with the API, I already check using Postman and it worked perfectly fine, Anyone know what went wrong?

0 Answers
Related