Vuetable-2无法与Laravel Passport一起使用

时间:2019-04-02 16:08:44

标签: laravel vuejs2 laravel-passport vue-tables-2

我正在使用laravel作为后端(带有Passport的API),并且我有vuetable-2来处理前端的数据。实际上,我正在使用客户API配置vuetable-2。首先,我已经使用externa API配置了vuetable,然后我将laravel配置为可以像预期的vuetable-2(json响应的格式)一样工作。

我已经用POSTMAN测试了我的api,并且一切正常。

enter image description here

当我使用客户API配置vuetable-2时,问题开始了。我总是得到:

  

401未经授权。未经身份验证。

我尝试将'auth:api'添加到kernel.php上的api中间件中,但没有任何变化...知道吗?

1 个答案:

答案 0 :(得分:0)

问题出在vuetable-2和axios。固定:

添加到vuetable-2:

public class SerElection extends HttpServlet{
  int cGhezzi=0, cPelliccia=0, cValente=0, cBussi=0, cFerri=0;

  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException,ServletException{
    String candid = request.getParameter("candidato");
    Cookie cookie = new Cookie(candid,candid);
    response.addCookie(cookie);
    String c = cookie.getName();
    if(c.equals("Ghezzi") || c.equals("Pelliccia") || c.equals("Valente") || c.equals("Bussi") || c.equals("Ferri")){
      response.setContentType("text/html");
      PrintWriter out = response.getWriter();
      out.println("<html>");
      out.println("<head>");
      out.println("<title></title>");
      out.println("</head>");
      out.println("<body>");
      out.println("<h3>I'm sorry but you've already voted</h3>");
      out.println("</body>");
      out.println("</html>");
      out.close();
    }
else{
      //ACCORDING TO THE CHOICE OF CHOICE INCREMENT ITS VARIABLE FOR STATISTICS
      if(candid.equals("Ghezzi")) cGhezzi++;
      if(candid.equals("Pelliccia")) cPelliccia++;
      if(candid.equals("Valente")) cValente++;
      if(candid.equals("Bussi")) cBussi++;
      if(candid.equals("Ferri")) cFerri++;
      //response.sendRedirect("/Elezioni/index.html");
  } //END ELSE
.
.
.

功能:

:http-fetch="myFetch"