-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of HttpClient, Newtonsoft.Json, or F# Async fails to fetch #16336
Comments
For http - you need to construct an |
Did you look at @SteveSandersonMS comments on size of JSON libraries. Do you want/plan to use Json.NET despite of its size? I mainly work with B2B customers where size of web apps are less important. Users typically have good connectivity and assets could be cached on the client. Therefore, I would like to have to additional functionality that Json.NET gives me although it makes Blazor apps larger. I would be curious to hear your thoughts on this. |
My personal take on this is: I use Json.NET in my day to day work on the server-side and it can do everything you could imagine. However, in 95%+ of cases you'd probably only need 10% of its feature set. So as long as you don't really need the advanced features of Json.NET in your application (and chances are, you don't), any other Json lib will probably do the job just as good and when they are smaller it's fine. That said, size for an SPA only matters when it's an app for end-users that is available through public internet. If you do a business app where you'd package the SPA in a mobile app (i.e. Cordova) or into an Electron package, or even if the environment is such that client browsers are on a local network with the web server serving the SPA, then a few hundred KB don't matter as much. Also, libraries are easily cacheable, so it usually is only a one-time download. So, I guess the most fitting answer is again: It depends ;) |
I wonder if it's possible to use the IL Linker to strip Json.Net? Especially if you'd only use a part of APIs in reality. I'd be nice as you'd get the flexibility of using only what you want but also not having the extra payload size that comes with all Json.Net's libs |
@gingters |
@rdavisau yes, it seems this is the same issue as aspnet/Blazor#370. I'm closing this as a duplicate. After adding Blazor as a dependency to the library project, I was able to use the |
I tried delegating to a class library to fetch data. The class library has only the core
HttpClient
methods such asReadAsStringAsync
, so I addedNewtonsoft.Json
as a dependency. When I run the app, the fetch fails. I think something is wrong either with the standard methods or use ofNewtonsoft.Json
. However, as I also used F# and anasync
computation, it's possible that is the culprit. Any pointers?Here's the reproduced call: https://github.com/panesofglass/blazorapp/blob/master/BlazorApp1/Pages/FetchData.cshtml#L43
Here's the implementation in the helper library (in F#):
https://github.com/panesofglass/blazorapp/blob/master/Library1/Library.fs#L24-L32
Update: I was able to remove the use of F# Async, and the fetch still fails.
The text was updated successfully, but these errors were encountered: