+ 4

Can't Access Weather Using fetch() ?

I am trying to fetch weather data from an online source but its giving me this error. If someone has any idea about this error please respond. I have tried many times but its not working out. Thank You ! /* Access to fetch at 'https://openweathermap.org/data/2.5/weather?q=London,uk&appid=373fbc6e4bf925e474d8ef40ad84bf31' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. */

6th Jul 2020, 8:48 AM
Johar Khan
Johar Khan - avatar
1 Resposta
+ 1
Looks like you're fetching from the wrong URL, the domain name part('https://example.com') of the URL is wrong, the correct one is 'https://api.openweathermap.org', not the one you provided in your question. Try it out and see if it works.
6th Jul 2020, 6:38 PM
Ryan
Ryan - avatar