How to create an ajax endpoint without js?

When using JS fetch api with the wordpress is set up your issue is with the body.

fetch passes body data in a way that wordpress can’t understand.

Your body: {} should be like this

body: new URLSearchParams({
    username: 'thewhitefang',
    password: '@bhishek01',
    action: 'login_ajax'
})

and you need to change your content-type as well. 'Content-Type': 'application/x-www-form-urlencoded'

I can’t really explain it well because i never really dived deep into this subject but im sure you could find everything you need about this.

Hope this helps =]