updateData static method
Implementation
static Future<dynamic> updateData(
{required String url,
required Map<String, dynamic> body,
Map<String, String> header = const {
'Content-Type': 'application/json'
}}) async {
try {
Response response = await put(
Uri.parse(url),
body: jsonEncode(body),
headers: header,
);
log('POST status: ${response.statusCode}');
if (response.statusCode == 200) {
if (response.body.isNotEmpty) {
return jsonDecode(response.body);
}
return null;
}
throw ApiFailedException(msg: 'failed to update the data :(');
} on ApiFailedException catch (e) {
log(e.toString());
return null;
}
}