Skip to content

Code Works. Change this: AuthService -> Register #12

@judismith

Description

@judismith

I'm not sure if this is a .Net 3.1 vs 5 issue. However, the Post call in the current code uses PostJsonAsync. I believe the correct call is PostAsJsonAsync.

Also even with using PostAsJsonAsync, the compiler throws an error because the return is an HttpResponseMessage and not a RegisterResult. As a whole, I believe the correct code is as follows:

public async Task<RegisterResult> Register(RegisterModel registerModel)
        {
            var result = await _httpClient.PostAsJsonAsync<RegisterModel>("api/accounts", registerModel);
            var registerResult = result.Content.ReadFromJsonAsync<RegisterResult>().Result;
            return registerResult;
        }

With this modification, the code works great. Thanks for a wonderful example!! I'm looking forward to your book.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions