Question with invalid away in async function
Why is the await on the same function invalid in the error call back, but not in the success. Does the event cause a conflict? It gives the error, unexpected reserved word.
const successCallBack = async function (position) {
try {
const { latitude, longitude } = position.coords;
const coords = [latitude, longitude].toString();
await model.fetchWeather(coords);
renderWeather();
} catch (error) {
console.log(error);
}
};
const errorCallBack = async function (error) {
try {
if ((GeolocationPositionError.code = 1)) {
document.getElementById("modal").addEventListener("submit", (e) => {
e.preventDefault();
const coords = mainView.getManualCoords()
await model.fetchWeather(coords);
renderWeather();
});
}
} catch (error) {
console.log(error);
}
};