search

Home  >  Q&A  >  body text

vue-resource - How to get csrftoken inconsistent error in laravel

When using vue-resource to send an ajax request in laravel, sometimes an error of inconsistent token will be returned, which is the picture below:

Question:
Instead of making this error disappear, how to get this error information in the response of the following error callback?

{
  // GET /someUrl
  this.$http.get('/someUrl').then((response) => {
    // success callback
  }, (response) => {
    // error callback
  });
}
我想大声告诉你我想大声告诉你2829 days ago574

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-16 16:52:59

    AppExceptionsHandler This class can customize exception handling laravel 5.3`

    public function render($request, Exception $exception)
        {
            if($exception instanceof TokenMismatchException){
                //你的响应
            }
            return parent::render($request, $exception);
        }`

    reply
    0
  • Cancelreply