简体   繁体   English

如何解决 Laravel 401(未经授权)错误

[英]How to resolve Laravel 401 (Unauthorized) error

How to resolve Laravel 401 (Unauthorized) error for a particular single URL.如何解决特定单个 URL 的 Laravel 401(未经授权)错误。

url is accessible directly but when request send using axios its how this error. url 可以直接访问,但是当使用 axios 发送请求时,它是如何出现这个错误的。

api_token: this.user.api_token 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链接: 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"但请确保您有“user.api_token”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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