` Random Quote Generator API

Random Quote Generator API

If I’m not wrong most probably you are here from the FreeCodeCamp.

And working on random quote generator.

So you are stuck at getting a random quote from the button click.

Just copy below code which will generate a random quote.

You Need jQuery For This To Work : Use jQuery in your website

$('#btn').on('click', function() {
    $.ajax({
      url: "http://api.icndb.com/jokes/random",
      jsonp: "callback",
      type: "GET",
      dataType: "jsonp",
      success: function (data) {
        $("#author").remove();
        $("#quote").append(data["value"]["joke"]);
      },
      xhrFields: {
        withCredentials: false
      }
    });
  });

Happy Coding

Also Read