简体   繁体   中英

In Javascript how do I pull mealtype from edamam nutritional API

I am trying to pull the mealtype from the following API.

https://developer.edamam.com/edamam-docs-nutrition-api

Reading the API understand that we need to use a POST request to get a response specifically for mealType data. However I am very confused on how the syntax would be written for this.

for example the user puts in lasagna and the api gives me the meal type which should be Italian.

Step 1, write a service that sends a post request when you run your script. I'm assuming here you're using node, so we'd have something like, let say APIGetter. In the api getter, you want to send out an http request.

I suggest using the request module . Now when you call this function, it'll return a json string inside a promise, containing a bunch of information. You can then deserialize it (turn it into a javascript object) using JSON.parse.

However, I don't think the API does what you think it does, it gives nutrition information given a list of ingredients. It will not categorize the food for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM