Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ResponseFetcher.cs:
- public async Task<T> GetApiResponseAsync(string url)
- {
- using (var client = new HttpClient()) {
- var response = await client.GetAsync(url).ConfigureAwait(false);
- var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
- return JsonConvert.DeserializeObject<T>(content);
- }
- }
- ---------------------
- LoginViewModel.cs:
- // Passing the task to RunTask():
- ResponseFetcher<Task> task = new ResponseFetcher<Task>("http://10.0.0.141:5000/");
- await task.GetApiResponseAsync("api/accounts/verify?username=test&password=test");
- Error: Start may not be called on a promise-style task.
Add Comment
Please, Sign In to add comment