What Did Alex Eat Today?

Code Climate

What Did Alex Eat Today? is a very basic Rails app that consumes the Alex's Dinner API. It also uses Unsplash's Source API to create a beautiful backdrop for incredibly useless information.

Javascript code for API

$(document).ready(function() {
  var reactions = [
    "Mmm delicious!",
    "Scrumptious!",
    "Mouthwatering!",
    "Delectable!"
  ];

  $.getJSON("https://alexsdinner.herokuapp.com/api/v1/dinner/today", function(data) {
    if (data.length === 1) {
      $("#food").text(data[0].food);
      var reaction = reactions[Math.floor(Math.random() * reactions.length)];
      $("#reaction").text(reaction);
    } else {
      $("#food").text("Alex has not eaten yet today. Check back later!")
    }
  });
});

Relevant CSS code for Unsplash Source

html {
  background: url(https://source.unsplash.com/category/nature/1800x1200) no-repeat center center fixed;
  background-size: cover;
}