feat: implement patch method in ApiClient and update recipe update logic in RecipeRepository
This commit is contained in:
@@ -57,17 +57,18 @@ class ApiClient {
|
||||
return _decodeOrNull(_guardResponse(response));
|
||||
}
|
||||
|
||||
Future<dynamic> deleteJson(String path, {String? token}) async {
|
||||
final response = await _client.delete(
|
||||
Uri.parse('$baseUrl$path'),
|
||||
headers: _headers(token: token),
|
||||
);
|
||||
return _decodeOrNull(_guardResponse(response));
|
||||
}
|
||||
|
||||
http.Response _guardResponse(http.Response response) {
|
||||
if (response.statusCode < 400) {
|
||||
return response;
|
||||
Future<dynamic> patchJson(
|
||||
String path, {
|
||||
Object? body,
|
||||
String? token,
|
||||
}) async {
|
||||
final response = await _client.patch(
|
||||
Uri.parse('$baseUrl$path'),
|
||||
headers: _headers(token: token),
|
||||
body: body == null ? null : jsonEncode(body),
|
||||
);
|
||||
return _decodeOrNull(_guardResponse(response));
|
||||
}
|
||||
}
|
||||
|
||||
final parsedBody = _decodeOrNull(response);
|
||||
|
||||
Reference in New Issue
Block a user