I have had this working before I swear. Am currently porting a project that is very heavy on synchronous flow (async: false is heavily used, but I'm getting annoyed at the deprecation warnings.
Basically I need a function that can get me an Ajax response from anywhere in the code. What I've currently got is
let processAjaxRequest = (endpoint, data, method = 'POST') => {
return $.ajax({
url: endpoint,
method: method,
data: data,
});
}
let makeAjaxRequest = async (endpoint, data, method='POST') => {
return await processAjaxRequest(endpoint, data, method)
}
$(document).ready(() => {
let result = makeAjaxRequest('/ajax/lang', '', 'GET')
console.log(result)
})
But the document.ready() function is still outputting a promise as opposed the pure result I'm trying to await for.