0

I have a vanilla HTML/Js page which submit to a Laravel API (Auth with Sanctum).

So if i call a Laravel Api route via ajax call i can easily set the Bearer token in the header for authentication like:

axios.get(data_source_url + "/articles", {
        headers: {
            Authorization: 'Bearer '+ token,
            Accept : "application/json; charset=utf-8"
        }
}).then...

But if i wanna submit my HTML formular via:

<form method="POST" action="https://myApi">
...
    <button type=submit>
</form>

i have no idea how to set Header attributes/information. Is it even possible to set a Header on a <form action>?

I know i could call a function with a <button type=button onclick="sendData"> but thats not my question.

Elias
  • 358
  • 1
  • 19

0 Answers0