Ionic 4 wordpress authentication

Good day Expert. Please I have a little worry if someone can help me out. I am using WordPress JWT plugins to authenticate users in my ionic 4 apps, but the issue am having is that when a user try to log in the first time it returns null, with this error message –
–HttpErrorResponse {headers: HttpHeaders, status: 404, statusText: “OK”, url: “…ecret=cs_xxxxxxxxxxx”, ok: false, …}, but the local storage returns the customer data and id with a toast showing login successful. when the user tries it the second time, that’s when the user will be authenticated. But I want user to be authenticated once the login is successful

Don’t know what I have done wrong. This is my code.


    this.platform.ready().then(() => {

      if((this.password != '') &&  (this.CFS.validateEmail( {

        console.log('Email: ',;

        console.log('Password: ',this.password);
        this.auth.loginCustomer(,this.password).then((response) => {


        console.log('Returned Token: ',response['token']);

        console.log('Returned user enamil: ',response['user_email']);

        this.CFS.presentToast('Login successful', 'buttom',2000, 'success');

        this.auth.getUserData( => {

         this.customerData = userData;

          console.log('Customer Data: ', this.customerData);

         let currentUserId = this.customerData[0].id;

         localStorage.setItem('currentUserId', currentUserId);

         let found = localStorage.getItem('currentUserId');

         console.log('local storage id', found);
      } else {

        this.CFS.presentToast('Invalid username or password', 'buttom',2000,'danger');


      } else {

        this.CFS.presentToast('Please fill  the form correctly', 'buttom',2000,'danger')





   customerData: any = {

    avatar_url: 'not found',


  constructor(private CFS: CommonfunctionService, private activatedRoute: ActivatedRoute, private auth: AuthService, private WC: WoocommerceService, private modalPop: ModalController) {

     ngOnInit() {  
    let isUserLoggedIn =  localStorage.getItem('currentUserId');


      this.customerData = data;

      console.log('user data', this.customerData);


    this.WC.getWalletBalance(isUserLoggedIn).subscribe((data) =>{

      this.mybalance = data;

      console.log('All Orders balance by a customer', this.mybalance);


please I need your assistance. Thanks