diff --git a/resources/scripts/app/Subnet.vue b/resources/scripts/app/Subnet.vue index 18b19b7..d92c33e 100644 --- a/resources/scripts/app/Subnet.vue +++ b/resources/scripts/app/Subnet.vue @@ -15,33 +15,32 @@ const results = ref( {} ); /** * Load subnet data based on input */ -const getSubnetData = async () => { - try { - // Enable loading state - isLoading.value = true; +const getSubnetData = () => { + // Enable loading icon + isLoading.value = true; - // Prepare request payload - const postData = new FormData(); - postData.append( 'subnet', subnet.value ); + // Create post data + const postData = new FormData(); + postData.append( 'subnet', subnet.value ); - // Send request and handle response - const response = await axios.post( '/api/subnet', postData ); + // Send request + axios.post( '/api/subnet', postData ).then( (response) => { const { data } = response; - // Update results and UI state - results.value = data.result; + // Load new block + isLoading.value = false; hasResults.value = true; - } catch (error) { - // Extract and show error message - const errorMessage = error.response?.data?.message || 'Something went wrong.'; + results.value = data.result; + } ).catch( (error) => { + isLoading.value = false; + + // Show error message + const errorMessage = error.response.data.message || 'Something went wrong.'; $toast.error(errorMessage, { position: 'top', duration: 1500, }); - } finally { - // Reset loading state - isLoading.value = false; - } + } ); } /** diff --git a/resources/scripts/main.ts b/resources/scripts/main.ts index cf90463..10f906a 100644 --- a/resources/scripts/main.ts +++ b/resources/scripts/main.ts @@ -4,7 +4,7 @@ import ToastPlugin from 'vue-toast-notification'; import 'vue-toast-notification/dist/theme-default.css'; // Import components -import Subnet from '@scripts/app/Subnet.vue'; +import Subnet from '@app/Subnet.vue'; // Initialize vue app function initializeApp(element: string, component: any): void { diff --git a/src/Http/Response.php b/src/Http/Response.php index 99d4fcb..493b88a 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -2,9 +2,9 @@ namespace Core\Http; +use Core\View\JsonRender; use Core\View\Render; use Core\View\Render\HtmlRender; -use Core\View\Render\JsonRender; class Response { diff --git a/src/View/Render/JsonRender.php b/src/View/JsonRender.php similarity index 83% rename from src/View/Render/JsonRender.php rename to src/View/JsonRender.php index 3dc68b5..31d3462 100644 --- a/src/View/Render/JsonRender.php +++ b/src/View/JsonRender.php @@ -1,8 +1,6 @@