• Here the function to get token

    /**
       * Check user credentials
       * @param {string} login
       * @param {string} password
       * @returns {Promise}
       */
      checkUserLogin(login, password) {
        return axios
          .post(<code>/jwt-auth/v1/token</code>, {
            username: login,
            password: password
          })
          .then(response => response.data);
      }

    This is how that function calls

    async checkUserInput() {
          try {
            const resp = await userApi.checkUserLogin(this.name, this.password);
            console.log(resp);
            if (resp.token) {
              console.log(resp.token);
              this.$store.commit("login/SET_APP_TOKEN", resp.token);
            }
          } catch (error) {
            console.error(error);
          }
        },

    If login or password incorect I got error in chrome’s console: GET http://tech.localhost/login/?errno=invalid_username 404 (Not Found)

    As you can see error’s content in get param. And in catch block i got just this Request failed with status code 404

Viewing 1 replies (of 1 total)
  • Thread Starter genuus

    (@genuus)

    So how I should get this kind of error? `{
    “code”: “jwt_auth_failed”,
    “data”: {
    “status”: 403
    },
    “message”: “Invalid Credentials.”
    }`

Viewing 1 replies (of 1 total)

The topic ‘Can’t get error response in JSON’ is closed to new replies.