performHttpRequest method
Future<Map<String, dynamic> >
performHttpRequest({
- required String method,
- required String url,
- required Map<
String, String> headers, - dynamic body,
- required Duration timeout,
override
Implementation
@override
Future<Map<String, dynamic>> performHttpRequest({
required String method,
required String url,
required Map<String, String> headers,
dynamic body,
required Duration timeout,
}) async {
if (!_isInitialized) {
await initialize();
}
try {
final options = <String, dynamic>{
'method': method,
'url': url,
'headers': headers,
'body': body,
'timeout': timeout.inMilliseconds,
}.jsify() as JSObject;
final requestPromise = _performWasmRequest(options);
if (requestPromise == null) {
throw const FittorWasmException(
'WasmHttpClient.performRequest not available');
}
final result = await requestPromise.toDart;
return (result as JSObject).dartify() as Map<String, dynamic>;
} catch (e) {
throw FittorWasmException('WASM request failed: $e', e);
}
}