Last active
February 14, 2021 18:26
-
-
Save shubhamnikam/37d9ff76701fb7162bfc456f764ba1c2 to your computer and use it in GitHub Desktop.
GithubController - wrong http call without HttpClientFactory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpGet("TestGithub/{userName}")] | |
| public async Task<IActionResult> TestGithub(string userName) | |
| { | |
| var httpClient = new HttpClient | |
| { | |
| BaseAddress = new Uri("http://api.github.com/"), | |
| DefaultRequestHeaders = | |
| { | |
| { "Accept", "application/vnd.github.v3+json" }, | |
| { "User-Agent", "HttpClientFactoryExample" } | |
| } | |
| }; | |
| var accountInfo = await httpClient.GetStringAsync($"users/{userName}"); | |
| return Ok(accountInfo); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment