HttpClient在create-react-app

时间:2019-07-12 18:31:50

标签: c# asp.net http asp.net-core get

我正在使用asp.net核心中的一些代码,部分代码获取url,并使用HttpClient和GetAsync方法进行获取请求。在构造函数中,我有
 private readonly HttpClient _client = new HttpClient();
在另一种方法中,_client用于执行get请求,例如

private async Task<string> GetContent(string url){
 var response = await _client.GetAsync(url);
}

当我从create-react-app项目中使用localhost:3000或http://localhost:3000时,总是会收到404 not found错误。我如何使它工作?它适用于Google等其他网站。它甚至适用于swagger正在使用的localhost网址。

0 个答案:

没有答案