Discussions

Ask a Question
Back to All

CORS error in browser for API animation methods

Hello!
I try to use anmation methods in my JS app.
Like this:

  const options = {
    method: 'GET',
    headers: {
      accept: 'application/json',
      authorization: `Basic ${DID_API.key}`,
      //"Access-Control-Allow-Origin" : "*",
      //"Access-Control-Allow-Methods" : "GET,POST,PUT,DELETE,OPTIONS",
      //"Access-Control-Allow-Headers": "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With",
      'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'
    }
  };
  
  fetch('https://api.d-id.com/animations?limit=100', options)
    .then(response => response.json())
    .then(response => console.log(response))
    .catch(err => console.error(err));

I try different options, but browser gives me error:
"Acess to fetch at 'https://api.d-id.com/animations?limit=100' from origin 'http://localhost:3000' 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."

From Postman it works fine.

How can I request animation in my app?