+ 8

Openweathermap API

I am trying to fetch data using OWM API. Everything works correctly for me in Sololearn android app and when I open my .html file in Chrome. But it does not work for some users who also use android app and for me in Sololearn WEB. https://code.sololearn.com/WvMQrQ3ugzzv/?ref=app This code when ran in SL WEB outputs "Function started" and stucks there while in Sololearn android app it works just fine. Is something wrong with me, my code or Sololearn? Also, how can I fix it?

10th Jul 2020, 12:47 PM
Artem 🇺🇦
Artem 🇺🇦 - avatar
3 Respostas
+ 10
Hey Artem. You're doing it wrong actually. Whole point of using async await is to not use the stressful .then() Everytime. You should never mix async await with .then(). also, make sure to handle it with try and catch block so if you get an exception then you can know what it is. //try running this on your device where your code fails to see what exception you're getting. https://code.sololearn.com/Wasai8c8doLV/?ref=app
10th Jul 2020, 1:08 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 6
🔫 Rick Grimes and ODLNT, thank you for your answers. The problem actually was in both of these things, now it works. Unfortunately I can mark only one of answers as best answer ☺
10th Jul 2020, 1:44 PM
Artem 🇺🇦
Artem 🇺🇦 - avatar
+ 5
Using the chrome debugging tool I see there is a Mixed content error message. Mixed Content: The page at 'https://code.sololearn.com/' was loaded over HTTPS, but requested an insecure resource 'http://api.openweathermap.org/data/2.5/weather?q=London&appid=3bc44202dbed05a11c6e3575e1e38b02'. This request has been blocked; the content must be served over HTTPS. On line 33 add an s to http https://code.sololearn.com/Wydk1iPZ1Yep/#html Using a pc.
10th Jul 2020, 1:14 PM
ODLNT
ODLNT - avatar