How to use response outside the function?

In response, there is only one value. So how can I use that response outside of function?
Whenever I tried to use outside function it is showing in console undefined.

this.adminService.getlastfid().subscribe( response =>{
      this.lastid = response ;

    let l_id = this.lastid;

What is probably happening is that the request is being run towards the end of the call stack, so your console.log statement is printing the right value, at that time.

Try logging the value within the response callback of your subscription.

I suspect this is yet another “how do I time travel?” question.

You may be interested in thread 1, thread 2, or thread 3.