我有这个代码,但是我收到了一个错误:错误CS0161'ApiCall.GetResponse(string,string,string)':并非所有代码路径都返回值
public class ApiCall
{
static readonly string ApiUrl = "http://localhost:1762/api/{0}/{1}?{2}";
public async Task<T> GetResponse<T>(string controller, string method, string prm) where T : class
{
var client = new System.Net.Http.HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.GetAsync(string.Format(ApiUrl, controller, method, prm));
var JsonResult = response.Content.ReadAsStringAsync().Result;
if (typeof(T) == typeof(string))
return null;
var rootobject = JsonConvert.DeserializeObject<T>(JsonResult);
return rootobject;
}
}
}
有人知道吗?