CORS problem in react form (add a Contact to the collection contacts)

PauliusG6
Participant

CORS problem in react form (add a Contact to the collection contacts)

Hello
I would like to add a Contact to the collection contacts.
I have seen an example on site https://constantcontact.mashery.com/io-docs
Also, I have tested my request in https://chrome.google.com/webstore/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm and it working for me. My contacts created successfully and I can see my new contact by next link https://app.constantcontact.com/pages/contacts/ui#contacts/...
 
 
So, I use next code in my react app:
 
const params = {...}
 
fetch(url, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer af******b',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(params)
});

 

I have next error:

Access to fetch at 'https://api.constantcontact.com/v2/contacts?action_by=ACTION_BY_VISITOR&api_key=mw*****kt' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: 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.

 

Why I can't create Contact by my form?

How I can create Contact by my form?

Can you help me, please?

 

0 REPLIES 0
Developer Portal

View API documentation, code samples, get your API key.

Visit Page