I am using fetch api inside a function so in success response i want to insert the value into a global variable but it is not doing this.
example code is
function getExcludeDates(){
var data;
fetch('/get-exclude-dates')
.then(res => res.text())
.then(text => {
data = text.data;
//$('#students_count_reservation').prop('disabled', true);
});
return data;
}
return data shows undefined in console log