How to handle API response using JS?

  • 0
    The API gives a response in this format:
    [{"link":"","sport":"","event":"Netherlands - Spain","country":null,"league":"International Friendly","dt_start":"2020-11-11 22:45:00","prognoz":"AH2 0","kf":"1.80","status":"0","id":"2111","pay":"0","aux":null,"res":null},{"link":"","sport":null,"event":"Argentina - Paraguay","country":null,"league":"South America. WC Qwal","dt_start":"2020-11-13 03:00:00","prognoz":"Under 3.5","kf":"1.60","status":"0","id":"2011017","pay":"0","aux":null,"res":null}]

    The request address looks like this:

    How can I make a request and process this data in order to insert it somewhere on the site? I don't know much about the topic, but I need to do it urgently.
    I tried to follow the example of the code I found in one of my projects.
    $.getJSON('http://domen/out_mini.php', function(data){console.log(data);})

    The console gives an error
    Access to XMLHttpRequest at ' domen / out_mini.php ' from origin ' localhost: 3000 'has been blocked by CORS policy: No' Access-Control-Allow-Origin 'header is present on the requested resource.

    What to do?
    JavaScript Anonymous, Sep 27, 2020

  • 2 Answers
  • 0
    What to do?

    Read Chernyshevsky))

    And on the topic well, 100,500 times have already been discussed what CORS is and how to deal with it.

    If the site is yours, then add the necessary headings. If not, then proxy requests through the backend.

  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!