在 WASM 中调用我的 API 的最佳方式是什么?
What is the best way to call my API in WASM?
我正在尝试连接到我的 API。
我正在使用 SwaggerClient 调用它,但是当我这样做时,我得到 System.PlatformNotSupportedException: 属性 AutomaticDecompression is not supported.
那么调用我的 API 以使其在 WASM 上运行的最佳方法是什么?
在 Uno 平台中使用 Web 服务(假设 http/json)与任何 .NET 应用程序一样。使用 HttpClient
我不熟悉 SwaggerClient,但我假设后台有一个 HttpClient。
对于 WebAssembly,您需要创建一个 WasmHttpHandler,然后将其作为 HttpClient 的 innerHandler 传入。
#if __WASM__
var innerHandler = new Uno.UI.Wasm.WasmHttpHandler();
#else
var innerHandler = new HttpClientHandler();
#endif
_httpClient = new HttpClient(innerHandler);
有关使用 HttpClient 的示例,请参阅 https://github.com/unoplatform/uado。
我正在尝试连接到我的 API。 我正在使用 SwaggerClient 调用它,但是当我这样做时,我得到 System.PlatformNotSupportedException: 属性 AutomaticDecompression is not supported. 那么调用我的 API 以使其在 WASM 上运行的最佳方法是什么?
在 Uno 平台中使用 Web 服务(假设 http/json)与任何 .NET 应用程序一样。使用 HttpClient
我不熟悉 SwaggerClient,但我假设后台有一个 HttpClient。
对于 WebAssembly,您需要创建一个 WasmHttpHandler,然后将其作为 HttpClient 的 innerHandler 传入。
#if __WASM__
var innerHandler = new Uno.UI.Wasm.WasmHttpHandler();
#else
var innerHandler = new HttpClientHandler();
#endif
_httpClient = new HttpClient(innerHandler);
有关使用 HttpClient 的示例,请参阅 https://github.com/unoplatform/uado。