• Resolved typlox

    (@typlox)


    I am currently working on a project with Ionic / Angular, and when sending the POST data to get the token, I am getting that error.

    message: “Error: The username field is empty.”

    
    logForm(){
        let user: User = {
          "username": this.loginForm.value.username,
          "password": this.loginForm.value.password
        }
        this._qService.login(user);
      }
    

    That is the method of my component class in Ionic

    
    public login(user: User) {
        let url = ${environment.jwt};
        return this.http.post(url, user).subscribe((resp: any) => {
          console.log(user);
          console.log(resp);
          if (resp.success && resp.statusCode === 200) {
            this.router.navigate(['/topics']);
            return this.saveStorage(resp.token, resp.id);
          }
          if (resp.success === false && resp.statusCode === 403) {
            const msg = 'Incorrect data'
            this.logError(msg);
          }
        })
      }
    

    That is the service where I do the POST to the endpoint

Viewing 1 replies (of 1 total)
  • Plugin Author Bagus

    (@contactjavas)

    Hi @typlox , it seems like both of your service and the code which calls the service are already correct. Would you mind to share your api url? I would like to try it.

    Im in Discord channel if you need faster response.

    Best,
    Bagus

Viewing 1 replies (of 1 total)

The topic ‘“Error: The username field is empty.”’ is closed to new replies.