Sunday, 16 Mar, 2025 -1015

How to use same project API in blade

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class YourController extends Controller
{
    public function showPage()
    {
        // Call your Laravel API
        $response = Http::get(url('/api/your-endpoint'));
        // Convert JSON response to array
        $data = $response->json();
        // Pass data to Blade view
        return view('your-blade-file', ['apiData' => $data]);
    }
}

Tags: api
Tags
Most Popular
img
02 Apr, 2024 view: 3808
img
02 Apr, 2024 view: 2558
img
01 Apr, 2024 view: 2453
img
01 Nov, 2023 view: 2273
img
26 Apr, 2024 view: 1538
img
02 Apr, 2024 view: 1471
img
01 Apr, 2024 view: 1355
img
18 Apr, 2024 view: 1265
img
09 Apr, 2024 view: 1250
img
10 Apr, 2024 view: 1171
img
26 Feb, 2025 view: 1111
img
16 Mar, 2025 view: 1015
Trending