r/learnjavascript • • May 22 '21

Why do some features don't work after deploying on the web?

I've created a website. When I test my website on my localhost, the browser does not throw any error. But after I deployed on the web, errors occurred. The background images on my CSS do not work, and my fetch API does not seem to work either. These are the errors show when I try to open the console.

These are my CSS codes for the background images that do not work.

This is what the fetch API should look like.

And this is how it looks like after deploying it on the web.

This is my code for the fetch API that doesn't work.

I'm sorry, I'm still new to this and this project is due next week so I need to fix this error asap. Thank you for understanding!

Best regards.

2 Upvotes

2 comments sorted by

1

u/[deleted] May 22 '21

Hello,

The last console error means that the file scripts/offer.json cannot be found by the fetch function, that is why it cannot load the data thus the further errors.

Thanks

1

u/igorskyflyer May 22 '21

Try removing the leading forward slash "/" for assets and scripts. 😉 If that doesn't work try "../assets/" and "../scripts/" respectively.