Working Get -reading from api
This commit is contained in:
@ -1,10 +1,39 @@
|
||||
namespace PostmanCloneUI
|
||||
using PostmanCloneLibrary;
|
||||
|
||||
namespace PostmanCloneUI;
|
||||
|
||||
public partial class Dashboard : Form
|
||||
{
|
||||
public partial class Dashboard : Form
|
||||
private readonly ApiAccess _apiAccess = new();
|
||||
public Dashboard()
|
||||
{
|
||||
public Dashboard()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void callApi_Click(object sender, EventArgs e)
|
||||
{
|
||||
systemStatus.Text = "Calling API...";
|
||||
resultsText.Text = "";
|
||||
// Validate the API URL
|
||||
if (_apiAccess.IsValidUrl(apiText.Text) == false)
|
||||
{
|
||||
InitializeComponent();
|
||||
systemStatus.Text = "Invalid URL...";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
resultsText.Text = await _apiAccess.CallApiAsync(apiText.Text);
|
||||
|
||||
systemStatus.Text = "Ready";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
resultsText.Text = "Error: " + ex.Message;
|
||||
systemStatus.Text = "Error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user