I wrote this code and it’s works perfect for me.
But when i try to convert it to fetch, dosen’t work because return a promise.
I don’t know how to use it as a async false on fetch.
'getProjectConstants': function(constArray)
{
var result='';
$.ajax({
type: "GET",
url: `${constProjectBaseUrl}/ajax/getProjectConstants/${constArray}`,
async: false,
dataType: "json",
success: function(data) {
result = data
}
});
return result
I tried to do like this, but dosen’t work
fetch(`${constProjectBaseUrl}/ajax/getProjectConstants/${constArray}`)
.then((response) => response.json())
.then((response) => {
// console.log(response)
return response
}) // end of .then((response) => {
.catch(error => {
console.log("[ajax.getProjectConstants] Error => " + error);
}); // end of .catch(error => {