Laravel 8 JWT Authentication Invalid Code [Solution] with Bearer Token

Laravel application could display a lot of error like invalid token when using JWT authentication due to lack of proper header request settings. to fix that you have make sure you add the bearer keyword and then concatenate your token along with it.

Let's take a look at an axios request made to load a user or validate a token using the header

 await axios({
        method: "GET",
        url: `/api/user`,
        headers: {
            "content-type""application/json",
            Authorization:  tokenHere
        },
    })


The above code works pretty well just for you to send data alongside with the headers. If you try it you will get an error. Below is the soluction code 

 await axios({
        method: "GET",
        url: `/api/user`,
        headers: {
            "content-type""application/json",
            Authorization: "Bearer " + token
        },
    })