nutrition-data | Code to create a sqlite db from USDA nutrition database | Database library
kandi X-RAY | nutrition-data Summary
kandi X-RAY | nutrition-data Summary
Code to create a sqlite db from USDA nutrition database
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of nutrition-data
nutrition-data Key Features
nutrition-data Examples and Code Snippets
Community Discussions
Trending Discussions on nutrition-data
QUESTION
I'm pretty new to JS and very very new to Node. I'm trying to make a very simple app that pulls JSON data from the edamam API (https://rapidapi.com/edamam/api/edamam-nutrition-analysis). I've got the API working, and I now want to use the data that the request returns, but it's stuck inside a callback function and I can't figure out how to access it outside of the function that retrieves it.
From what I can tell, it's something to do with the async nature of Node. I've tried re-ordering it in every way I can think of (for over 6 hours!), but all I ever get is undefined variables. I'm figuring that's because they haven't been set yet, but I don't quite have enough of a handle on callback functions to understand how to fix this.
Eventually I want to be able to use the JSON data to update the contents of HTML elements.
...ANSWER
Answered 2018-Dec-31 at 11:07the final console.log is ALWAYS undefined, whereas I am wanting it to return the value on line of cals (result.body.totalNutrients.ENERC_KCAL.quantity);
This is because of the asynchronous nature of the nodejs. To get value from requestData()
, you need to pass cal
as a value to the callback.
Making those changes,
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install nutrition-data
You can use nutrition-data like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page