Need help to fetch data from product table using sql query in laravel
via laravel passport api authentication.
Create a route in your api.php
Route::middleware(['auth:api', 'throttle:60'])->group(function () {
Route::get('products', 'Api\ProductController@getProducts');
}
Write the getProducts function in your ProductController
public function getProducts(){
return Product::all();
}
Send a get request into /api/products with Authorization header. Its value will be your access token. Do not forget to add 'Bearer ' before it. (there is space between your access token and Bearer word).
I recommend you to use Postman for this job.