Rails Request.JS encapsulates the logic to send by default some headers that are required by rails applications like the X-CSRF-Token.
Just import the FetchRequest class from the package and instantiate it passing the request method, url, options, then call await request.perform() and do what do you need with the response.
To authenticate fetch requests (eg. with Bearer token) you can use request interceptor. It allows pausing request invocation for fetching token and then adding it to headers:
FetchRequest sets a "X-Requested-With": "XmlHttpRequest" header. If you have not upgraded to Turbo and still use Turbolinks in your Gemfile, this means you will not be able to check if the request was redirected.