For my nodejs server I was just using cors module to solve the problem. I installed a plugin for wordpress that allows all origins links, but still get No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.

I think I need to solve the cors problem inside the javascript file itself. I'm using axios for rest api requests so I don't know how to solve this correctly.

My JS ajax call:

axios.get('rest api server here')
    .then(function (question) {
      var data = question.data;

  const questions = [];
  $.each(data, function(index, value) {
    console.log(JSON.stringify(value.the_question, null, "\t"))
    console.log(JSON.stringify(value.the_answer, null, "\t"))
    console.log(JSON.stringify(value.the_choices, null, "\t"))
    questions.push(new Question(value.the_question, value.the_choices, value.the_answer)) .....

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.