Forkify Web app (part 5 – Displaying the recipe view)

forkify-part5 source

install npm modules: npm install
run web app: open command line and type ‘npm run start’

We implement our files according to MVC paradigm:

We first create a recipe view file

src/js/views/recipeViews.js

We use fractional module to calculate integer display of fractions: npm install fractional –save

This is so that we can apply the effects to ingredient.count and ingredient.unit

renderRecipe is used in our controller (index.js) to display html when we click on an item. We use the html from the template, and then add data to it via the recipe object.

As you can see, when we fetched data for the recipe successfully, we then render the recipe.
src/js/index.js

src/js/models/Recipes.js