Skip to content

Using jQuery with Axios to get Ron Swanson quotes from an API

License

Notifications You must be signed in to change notification settings

nick3499/rs_quotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rs_quotes

Using jQuery with Axios to get individual Ron Swanson quotes from an API

Example Image

example

API

Ron Swanson quotes

Libraries

Script

  • with each click event, jquery replaces the button text with a Ron Swanson quote.
  • axios backend gets the text string from the API.
$('#get_quote').click(function() {
  axios.get("https://ron-swanson-quotes.herokuapp.com/v2/quotes")
  .then(function(res) {
    $('button').text(res.data);
  })
  .catch(function(error) {
    console.log(error);
  })
});

Script (Alternate)

  $('#get_quote').click(function() {
    fetch("https://ron-swanson-quotes.herokuapp.com/v2/quotes")
    .then(res => res.json())
    .then((data) => {
      this.friends = data
      $('button').text(data);
    })
  });

ko-fi

About

Using jQuery with Axios to get Ron Swanson quotes from an API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages