I am trying to fetch Data form OpenWeather API.According to the docs the response is JSON.However I am getting an error of :
SyntaxError: Unexpected token < in JSON at position 0
useEffect(() => {
fetch(`api.openweathermap.org/data/2.5/weather?q=${CITY_NAME}&appid=${API_KEY}`)
.then(
(res)=> res.json()
.then((data)=>{
console.log(data)
})
.catch((error)=>{
console.log(error)
})
)
}, [])
I also have a status code of 304: Not Modified when I looked through the developers tool.
There were few question which matched my problem but none of them solve my problem like: Fetching JSON returns error Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 and
React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0