update static method
update a object with id
at collection
with the new data
, returns updated object,
throws StrapiResponseException if response is failed
Implementation
static Future<Map<String, dynamic>> update({
required String collection,
required String id,
required Map<String, dynamic> data,
}) async {
StrapiObjectListener._informLoading(id);
final path = collection + "/" + id;
final response = await Strapi.i.request(path, method: "PUT", body: data);
if (response.failed) {
throw StrapiResponseException(
"failed to update single object with id $id at collection $collection",
response,
);
}
if (!response.failed) {
StrapiObjectListener._inform(response.body);
}
return response.body.first;
}