操控平台后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
764 B

3 months ago
3 months ago
using Admin.Bodk.Device;
using Newtonsoft.Json;
3 months ago
namespace Admin.NET.Core.Service;
public class ApiService
{
private readonly HttpClient _httpClient;
public ApiService()
{
_httpClient = new HttpClient();
}
3 months ago
public async Task<ResultData> GetApiResponseAsync(string url)
3 months ago
{
HttpResponseMessage response = await _httpClient.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
3 months ago
var result = JsonConvert.DeserializeObject<ResultData>(responseBody);
if (result.IsSuccess)
{
return result;
}
else
{
throw Oops.Oh(result.Message);
}
3 months ago
}
}