apiPatch method
Future
apiPatch({
- required String endpoint,
- Map<
String, dynamic> ? body, - required BuildContext context,
PATCH method for REST API call
Pass UserModel
as user
required for authentication based on app token
Pass String as endpoint
Implementation
Future<dynamic> apiPatch({
required String endpoint,
Map<String, dynamic>? body,
required BuildContext context,
}) async {
try {
// String? token = await FirebaseAuth.instance.currentUser!.getIdToken();
_dio.options.headers["x-api-key"] = "";
// log(apiBaseUrl + endpoint);
// log(body.toString());
dio.Response rawResponse = await _dio.patch(apiBaseUrl + endpoint,
data: body,
options: dio.Options(
followRedirects: false,
validateStatus: (status) {
return status! < 300;
},
));
return rawResponse.data;
} on dio.DioException catch (e) {
log(e.toString());
log(e.message.toString());
throw ApiError.fromResponse(e.response!);
}
}