-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get servings? #7
Comments
Anyone can help me, please? |
@ariefpurnamamuharram Recipe has Serving object in it from which you can get all the details. Also Food has an array of Service objects which give details about all kinds of different servings. May I know which Recipe/Food are you trying to retrieve? |
No, it is not about recipe. |
In that case, you are looking for Food. String key = "ENTER YOUR KEY HERE";
String secret = "ENTER YOUR SECRET HERE";
FatsecretService service = new FatsecretService(key, secret);
String query = "Indomie";
Response<CompactFood> response = service.searchFoods(query);
List<CompactFood> results = response.getResults();
for (CompactFood food: results) {
Food f = service.getFood(food.getId());
if (f.getServings() != null && f.getServings().size() > 0) {
// The following line will give you Serving object.
Serving serving = f.getServings().get(0);
System.out.println("servingDescription: " + serving.getServingDescription());
System.out.println("servingUrl: " + serving.getServingUrl());
System.out.println("calories: " + serving.getCalories());
}
} You can find more about Serving object here. There is a lot of information you will get from this object, like calories, carbohydrates, proteins, etc. |
I try to implement the code, but I encountered some errors. What should I do? @ranesr |
@ranesr can you help me by giving me the full codes of the example? |
@ariefpurnamamuharram Have you added this to your |
Yes, I have. But it doesn't resolve my problem. @ranesr |
Any solution for my problem, please? @ranesr |
@ariefpurnamamuharram Can you share your |
@ranesr |
Hello,
Can you help me how to get serving details?
Thank you.
The text was updated successfully, but these errors were encountered: