Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

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

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);
        });
      });
      });
    } 
question from:https://stackoverflow.com/questions/65942604/how-to-declare-a-variable-with-a-value-from-console-correctly

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...