AJAX : Axios - Get Request Ex.

In this example below you will see how to do a AJAX : Axios - Get Request Ex. with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by tanhimawan, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright tanhimawan ©
  • HTML
  • CSS
  • JavaScript
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    

/*Downloaded from https://www.codeseek.co/tanhimawan/ajax-axios-get-request-ex-pdoNZX */
        
    

/*Downloaded from https://www.codeseek.co/tanhimawan/ajax-axios-get-request-ex-pdoNZX */
        var url = 'https://opentdb.com/api.php?amount=1';

axios.get(url)
.then(function() {
  console.log(res.data.results[0].question);
})
.catch(function(){
  console.log("ERR");
})
    

Comments