jquery.get как задать setTimeout для ajax запроса
Я хочу задать ждать ответ от сервера 3 секунды, если ответа нету - продолжить работу кода
Как это правильно реализовать?
у меня есть данный код
try {
const geocode = await jQuery.get('https://maps.googleapis.com/maps/api/geocode/json?address=' + addressValue + '&key=' + GoogleMapsAPIkey);
if (geocode.status === 'OK') {
let response = await jQuery.get(RequestHelp.ajaxUrl, {
'action': 'store_search',
'lat': geocode.results[0].geometry.location.lat,
'lng': geocode.results[0].geometry.location.lng,
'max_results': 1,
'search_radius': 20,
'filter': 86,
});
if(response !== 'undefined' && response[0].distance <= 20){
return response;
}
return null;
} else {
return null;
}
} catch (err) {
console.log(err);
}