I'm trying to test my API using postman, but when I hit the POST
request, it's always throws me to the welcome page. I already set the XSRF token inside but still not working.
This is my api.php
routes:
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::resource('products/{product}/feedbacks', 'FeedbackController');
This is my store method from FeedbackController
:
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\StoreFeedback $request
* @return \Illuminate\Http\Response
*/
public function store(Product $product, StoreFeedback $request)
{
$product->addFeedback(
$request->validated()
);
return response()->json([
"status" => "success",
"message" => "Your feedback has been submitted."
], 200);
}
Here is my web.php
file:
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::resource('product-categories', 'ProductCategoryController')->parameters([
'product_category' => 'productCategory'
]);
Route::resource('product-sub-categories', 'ProductSubCategoryController')->parameters([
'product_sub_category' => 'productCategory'
]);
And here is the screenshot of my postman request: Link to the screenshot