Skip to content

sagites/summitAfrica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Meal Plan Nutrition API

Overview

This API route fetches a user’s latest meal plan and enriches it with nutritional data. It provides a structured breakdown of calories, protein, fat, and other values for each meal in the plan.

The endpoint:

  • Authenticates the user via their token.
  • Retrieves the most recent meal plan from the database.
  • Fetches nutrition data from the CalorieNinjas API for each meal.
  • Merges and sums nutritional values across multiple items if the API splits a query into parts.
  • Returns a clean, structured response with per-meal nutrition or appropriate error messages.

Why I’m Proud of This

This project was a real challenge and learning milestone for me:

  • Finding the right API was not easy.
  • The CalorieNinjas response breaks down queries (e.g., sending banana chicken suya pizza returns nutrition for each item separately).
  • The main difficulty was summing and restructuring the results into one usable format.
  • I had to revisit and apply JavaScript fundamentals like map, reduce, and object spreading to merge data effectively.

Example Flow

  1. User requests their nutrition data.
  2. API checks authentication.
  3. API fetches the user’s latest meal plan.
  4. For each meal title, the CalorieNinjas API is queried.
  5. Responses are summed and merged.
  6. API responds with structured nutrition data.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published