Laravel POST JavaScript call CSRF is not defined
I have the following function: public function search(Request $request) { return "Hello"; } Route: Route::post(‘/items/search’, [ItemController::class, ‘search’])->name(‘items.search’); JS: try { fetch(‘localhost:8000/items/search’, { headers: { "X-CSRF-TOKEN": {{ csrf_token() }} }, method: ‘POST’, body: "TEST" }) .then(response => response.text()) .then(data => alert(data)); } catch (error) { alert(error); alert(‘Failed to search items.’); } When I execute the JS… Read More Laravel POST JavaScript call CSRF is not defined