Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
Integrating API with Wordpress

I've been working on this for months now and have talked with my host, the company etc and I can make my api call work on their developer page which has example code to test their API but for the life of me I cannot get it to work on my Wordpress site and it is very much needed.

My initial code is as follows:

const options = {
  method: 'POST',
  headers: {
    Accept: '*/*',
    'Content-Type': 'application/json',
    Authorization: 'Basic XXXXXXXREDACTEDXXXXX'
  },
  body: JSON.stringify({firstName: 'John', lastName: 'Doe', phoneNumber: '5444455555'})
};

fetch('https://a.eztexting.com/v1/contacts', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

The first error I receive is: Access to fetch at 'https://a.eztexting.com/v1/contacts' from origin 'https://businessofimagination.com' 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.

after trying many different headers all over Wordpress and my theme I finally included: "mode: 'no-cors'," into my code

updated code is as follows:

const options = {
  method: 'POST',
  mode: 'no-cors',
  headers: {
    Accept: '*/*',
    'Content-Type': 'application/json',
    Authorization: 'Basic XXXXXXREDACTEDXXXXXX'
  },
  body: JSON.stringify({firstName: 'John', lastName: 'Doe', phoneNumber: '5444455555'})
};

fetch('https://a.eztexting.com/v1/contacts', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Now the errors I receive are: POST https://a.eztexting.com/v1/contacts 403 (403 forbidden) and SyntaxError: Unexpected end of input

I don't understand why it refuses to work, or what in Wordpress is preventing this. Please any help would be incredible. This has been an incredibly frustrating journey for something that in theory should work fairly seamlessly.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!