The error is as such:
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Current code:
window.addEventListener('load', () => {
const locatoin = document.querySelector('#location');
const tempNum = document.querySelector('#temp');
const description = document.querySelector('#description');
const APIkey = 'myAPIkeyHere';
var lat;
var long;
var currentPos;
if (navigator.geolocation) {
currentPos = navigator.geolocation.getCurrentPosition(position => {
lat = position.coords.latitude;
long = position.coords.longitude;
});
const api = `api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${long}&appid=${APIkey}`;
fetch(api)
.then(response => {
return response.json();
})
.then(data => {
console.log(data);
})
}
})
function refresh() {
location.reload();
}
I do not get any errors up until then and if I manually search the API url request it gives me the json data.
Thanks.