I wanted a simple way to display text and author into HTML like this:
text: You can observe a lot just by watching
author: Yogi Berra
Here, I tried to do it with jQuery and it's returning blank on the screen and undefined when logged out unless I removed text from (data.text).
$.ajax({
url: "https://type.fit/api/quotes",
method: "GET"
}).then(function(data) {
$("#text").text(data.text);
$("#author").text(data.author);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
<p id="text"></p>
<p id="author"></p>
</div>
What am I missing here?
JSON.parse()before.