CORS header Access-Control-Allow-Origin missing

I am getting a CORS error when trying to load data from certain websites.
states =(await fetch(“”)).json()

This raises the error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Why is this happening only with certain websites and not with the ones in the examples?

Also, if anyone could suggest a way to load data in from a local server that would be very helpful.

Just read this. Sorry, for not reading the docs first.