Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

APIs Posting Data with fetch()

Joseph Michelini
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Joseph Michelini
Python Development Techdegree Graduate 18,692 Points

When I post, it doesn't post to console. But after a bit I am receiving this super weird error. Help!

What's going on here? I feel like it's beyond the scope of this course but I could be wrong. This error only shows up after maybe 30 seconds? And in the meantime the comment has not been logged to the console. I've resorted to using the "final" code just to make sure I didn't make any errors of my own and it still happens.

alt text

Also, if for some reason you can't zoom in on that here, here's the Imgur link: https://imgur.com/IoIJ2Em

Thanks!

1 Answer

Steven Parker
Steven Parker
208,505 Points

CORS is a security feature in browsers that prevents a page loaded from one site from accessing information from a different site unless it has explicit permissions added by the systems in the HTTP message headers.

I think the workspace server might add these permissions automatically; but if you're working on a system that doesn't do this by default, you'll need to provide server configuration (or code) to allow CORS access.