Accessing value outside frappe call

I have assigned a global variable and then frappe call is initialized and the value (after callback) is passed to that global variable but it isn’t been called there. Only if i am using array’s push method then it is working but I want the creation of doctypes (only date).
Here’s the code:

       var date_s=[];
       frappe.call({
    	method:"frappe.client.get_list",
    	args: {
        	doctype:"doc",
			fields: [ 'creation'],
			filters: {'name': rec_id_s},
	
    		  },
    	callback: function(r) {
			var a=r.message;
			var date=a[0]['creation'];
			date=date.substring(0,10);
			date_s.push(date)
			
    						  }
					});


console.log(date_s)

Is there any other way to access the global variable .

Also is there any way to directly get creation of that doctype without frappe call ??

solved.
was missing async

1 Like

can you please specify where you made the change to solve this problem. I am facing the same problem. :confused:

1 Like

I was forgetting one parameter as

async:false, 

Use this just above callback function

3 Likes