Skip to content

Forkify: cookingTime is Undefined #454

Open

Description

@Revoj-a

Why the cookingTime always renders undefined? I tried every id's but it always undefine.

recipe = {
id: recipe.id,
title: recipe.title,
publisher: recipe.publisher,
sourceUrl: recipe.source_url,
image: recipe.image_url,
servings: recipe.servings,
cookingTime: recipe.cookingTime,
ingredients: recipe.ingredients,
};

${ recipe.cookingTime }

Activity

  1. Iman5210 commented on Jul 23, 2025

    @Iman5210

    It seems your issue is that recipe.cookingTime is undefined or has no value. Here are a few things to check:
    Inspect the Original recipe Structure
    Is the recipe object coming from something like an API or database? Make sure that before creating the new object, the original recipe. cookingTime actually exists.

    Log the Original Value Before Creating the New Object
    Try this before building your recipe = { ... } object:
    js console.log(recipe.cookingTime);
    If it logs as undefined, then either the original data doesn't contain that value or the key name is incorrect.

    ⚠️ Check for Key Name Differences
    It might be cookingtime instead of cookingTime. If you're using an API, key names are often written in snakecase. Try:
    js cookingTime: recipe.cooking_time

    🎯 Suggested Fix
    If you're sure the original recipe has cooking_time but it isn't showing, you could use destructuring or manually map the value to a new key name.

    Want to take a look at the full API response or a sample of the data together? It might just be a small detail that's been missed 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions