操控平台后端代码
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

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