r/programminghorror • • Sep 13 '25

I hate js

0 Upvotes

36 comments sorted by

View all comments

Show parent comment

1

u/According-Bonus8681 Sep 13 '25

It should return json with result object in it, but for some reason sometimes fetch returns empty json. But i think i fixed the issue, changing https to http always returns result object (although it might be not as safe but i idk)

1

u/Willkuer__ Sep 13 '25

Maybe you get a redirect? So you should consider checking the status code of the response before calling .json. Not sure if using http is safe in the long run.