Skip to content

Commit

Permalink
fix: fixing error message
Browse files Browse the repository at this point in the history
  • Loading branch information
josephines1 committed Feb 12, 2024
1 parent a831f34 commit 18c413e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
7 changes: 2 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="container">
<a class="navbar-brand" href="index.html">TasteTrack</a>
<button
class="navbar-toggler"
class="navbar-toggler collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarNav"
Expand All @@ -29,10 +29,7 @@
>
<span class="navbar-toggler-icon"></span>
</button>
<div
class="collapse navbar-collapse justify-content-end"
id="navbarNav"
>
<div class="navbar-collapse collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="index.html">Home</a>
Expand Down
18 changes: 16 additions & 2 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
function randomMeal() {
$(".result-container").html(
`<div class="d-flex justify-content-center mt-5">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>`
);

$.ajax({
url: "https://www.themealdb.com/api/json/v1/1/random.php",
dataType: "json",
type: "get",
success: function (response) {
console.log(response);
showResult(response);
},
});
Expand All @@ -15,6 +22,13 @@ $("#swipe-button").on("click", function () {
});

function searchMeal() {
$(".result-container").html(
`<div class="d-flex justify-content-center mt-5">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>`
);
$.ajax({
url: "https://www.themealdb.com/api/json/v1/1/search.php",
data: {
Expand All @@ -32,7 +46,7 @@ function showResult(response) {
$("#instruction-order").html("");
$("#ingredients-list").html("");

if (response !== null) {
if (response.meals !== null) {
let meal = response.meals[0];
if (meal.strTags === null) {
meal.strTags = "-";
Expand Down

0 comments on commit 18c413e

Please sign in to comment.