CORS Error while calling external api using ajax

  ajax, api, cors, javascript

I’m developing an online code editor web application. I’m using Spring Boot for backend and glot.io for running my code snippets. For testing purpose I used ajax to do GET request to display the languages inside browser’s console. My html code is

<body>
    <p></p>
    <button onclick="loadData();">click</button>
</body>
<script>
   const loadData =() =>
    {
        $.ajax({
            url: "https://run.glot.io/languages",
            method: "GET",
            success: function(res) {
                console.log(res);
            }
        })
    }
</script>
</html>

While making ajax request I got error like this!
enter image description here
I can’t do any server side modifications since I’m using External API. Can anyone help me to resolve this error?

Source: Ask Javascript Questions

LEAVE A COMMENT