<a href="{{ url('/home') }}">Home</a>
<a href="{{ route('logout') }}" onclick="event.preventDefault();document.getElementById('logout-form').submit();">Logout</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display:none">
@csrf
</form>
I am trying to submit the form above but keeps returning this error
(index):36 Uncaught TypeError: Cannot read properties of null (reading 'submit')
Can someone tell me what am I doing wrong here please?
I found out what was wrong. The problem was that I had a form within another form. Thanks guys anyway.