I tried to send the data from the database to the front-end (laravel-vue) I use laragon and PHP 8.1.22.
Steps that I follow to send data:
- I add this script to ../resources/js/components/Invoice/index.vue
<script setup>
import { onMounted , ref } from 'vue';
let invoices = ref([])
const getInvoices = async () => {
let response = await axios.get("/api/get_all_invoice")
console.log('response' , response)
}
onMounted(async() => {
getInvoices()
})
</script>
In the ../routes/api.php
use App\Http\Controllers\InvoiceController; Route::get('/get_all_invoice',[InvoiceController::class,'get_all_invoice']);go to the controller and add the function
get_all_invoice
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Invoice;
class InvoiceController extends Controller
{
public function get_all_invoice(){
$invoices = Invoice::all();
return response()->json([
'invoice'=>$invoices
],200);
}
}
To solve this problem I tried to enable the extension=pdo_mysql extension=pdo_pgsql
in the php.ini for the PHP 8.1.22 in laragon folders and I restart laragon but I have no result.
When I add this code:
<?php phpinfo(); ?>
To welcome.blade.php and I searched about pdo in the table said no value for pdo drivers is that mean that the pdo is not enabled or is that the default setting?
hy finally it worked I changed the script for getting the data and I restarted Laragon and vs code too