简体   繁体   中英

How to resolve Laravel 401 (Unauthorized) error

How to resolve Laravel 401 (Unauthorized) error for a particular single URL.

url is accessible directly but when request send using axios its how this error.

api_token: this.user.api_token

         axios.post("http://foo",
         {headers: { 'Authorization' : 'Bearer '+ api_token}})
         .then(response => {
                    //action
                })

link: https://forum.vuejs.org/t/401-unauthorized-vuejs-laravel-and-passport/59770

or

       postComment() {
      axios.post('/api/posts/'+this.post.id+'/comment', {
        api_token: this.user.api_token,
        body: this.commentBox
      })

but make sure that you have "user.api_token"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM