Ask coding questions

← Back to all posts
How to use
Coder100 (18934)

I need help posting data to for a project I am working on.
Whenever I do this:

fetch('[id]/users/1', {
  headers: {
    'Content-type': 'application/json'
  method: 'POST',
  body: { name: 'jon snow', age: 31 },

as shown in the documentation,
it does not work and returns this:

Access to fetch at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

How do I surpass this?