post method
Make a POST request with JSON body
Implementation
Future<ApiResponse> post(
String endpoint, {
Map<String, dynamic>? body,
Map<String, String>? params,
}) async {
try {
final uri = Uri.parse(
'${ScanProConfig.apiUrl}$endpoint',
).replace(queryParameters: params);
final response = await _client
.post(
uri,
headers: _getHeaders(),
body: body != null ? json.encode(body) : null,
)
.timeout(ScanProConfig.timeout);
return _handleResponse(response);
} catch (e) {
return ApiResponse(success: false, error: e.toString());
}
}