Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 2, 2022 15:16
Show Gist options
  • Save BetterProgramming/40ad1637ea629a7126ed814741daeb21 to your computer and use it in GitHub Desktop.
Save BetterProgramming/40ad1637ea629a7126ed814741daeb21 to your computer and use it in GitHub Desktop.
<!DOCTYPE html> <!-- Declaring that's that the file is html-->
<html lang="en"> <!-- Showing that the document is in English--><head><title>JavaScript - read JSON from URL</title>
<!-- Importing JQuery-->
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<div class="entree0"></div>
<script>
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1; // Months start at 0!
let dd = today.getDate();
var todayy = new Date();
if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;
const formattedToday = mm + '/' + dd + '/' + yyyy;
console.log(formattedToday)
mylink = "https://cors-anywhere.herokuapp.com/https://www.sagedining.com/microsites/getMenuItems?menuId=110277&date=" + formattedToday + "&meal=Lunch";
$.get('mylink', function(data) {
console.log(mylink)
var entree0 = `${data["Entrées"][0].name}`
$(".entree0").html(entree0);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment