How to declare a variable with a value from console correctly?

0

Issue

Good day everyone, I have this problem where I can’t put value from console to a variable correctly. When I try to run it, it gives an error like this but I successfully fetch the record user_id from login page to log page. I want to put the value correctly for my query but I can’t. I hope you can help me.

Here’s the code.

  async loadUsers(){

      return new Promise(resolve => {


        this.storage.get('storage_xxx').then((res) => {
          
        let body = {
          aksi: 'load_users',
          user_id: console.log(res.user_id)
        }
        
        this.accsPrvds.postData(body, 'proses_api.php').subscribe((res:any)=>{
          for(let datas of res.result){
              this.users.push(datas);
          }
          resolve(true);
        });
      });
      });
    } 

Solution

Use directly without console log

let body = {
       aksi: 'load_users',
       user_id: res.user_id
}
//If you still want print that then 
console.log(res.user_id);

Answered By – Kshitij

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More