Skip to content
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

issue with IHttpFactory DI in constructor #956

Open
jthegeman opened this issue Aug 3, 2020 · 0 comments
Open

issue with IHttpFactory DI in constructor #956

jthegeman opened this issue Aug 3, 2020 · 0 comments

Comments

@jthegeman
Copy link

I am trying to follow the directions of Using HttpClientFactory

I have services.AddRefitClient<IWebApi>(settings) .ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.myapi.com")); in my startup class.

and my service class

public class ApiService 
{
    public ApiService(IWebApi webApi)
    {
        _webApi = webApi;
    }

    private readonly IWebApi _webApi;

    public async Task<IActionResult> Index(CancellationToken cancellationToken)
    {
        var thing = await _webApi.GetSomethingWeNeed(cancellationToken);
        return View(thing);
    }
}

I get an error when I try to create an instance of the ApiService in a View saying that there is not a constructor with 0 parameters.

What am I missing on the DI or Refit side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant