samedi 25 septembre 2021

how can i access sessions on laravel?

i can access the Session::get('LoggedUser') on the index function with no problem.

enter image description here

but i can't access the session when i send an axios post request to the getProjects() function.

enter image description here

Controller code:

class ProjectController extends Controller
{
    public function index(){
        //dd(Session::get('LoggedUser'));
        return view('user.project.dashboard');
    }

    public function getProjects(){
        dd(Session::get('LoggedUser'));
    }
}

compnent code:

mounted(){
            axios.post('/api/user/projects')
                .then(response=>{
                    console.log(response.data.data)
                })
        }

api.php:

Route::prefix('user')->group(function(){
    Route::post('projects',[UserProjectController::class, 'getProjects']);
});


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire