C
C#3y ago
İrşat

How to process IActionResult Ok(value) return in back end. [Answered]

string url = "Read/GetPost?postid=" + postid;
var apiResponse = await _httpClient.GetFromJsonAsync<>(url);
string url = "Read/GetPost?postid=" + postid;
var apiResponse = await _httpClient.GetFromJsonAsync<>(url);
What should I write inside the getfromjsonasync?
5 Replies
İrşat
İrşatOP3y ago
I might need to just put my model in there but isn't this a HttpResponse? How can I get status code and stuff
ConfusedPenguin
You are correct, the URL is what you need. You can also provide a response type (i.e. the type that will be returned from the method-call). However, this is an extension method that deserializes the response into the type you proivide, thus not returning the HttpResponse. Use the regular .GetAsync() if you need to get the HttpResponse object instead of the deserialized http response.
İrşat
İrşatOP3y ago
GetAsync worked just what I needed, thanks
ConfusedPenguin
No problem.
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server