Recipe - Food - Nutrition

부분 유료
Verified
분류별 David | 업데이트됨 hace 22 días | Food
인기

9.9 / 10

지연 시간

518ms

서비스 수준

100%

Health Check

N/A

모든 토론으로 돌아가기

How to input array as parameters for complex search?

Rapid account: Parynaz
parynaz
hace 7 años

It works fine when I do the following with just a query and an array named selected = [“Vegetarian”] for complex search:

return $http.get("https://spoonacular-recipe-food-nutrition-v1.p.mashape.com/recipes/searchComplex?addRecipeInformation=false", 
							{params: {'query': query, 'diet' : selected }}).then(
			function(payload) {
				var recipes = payload.data;
				return recipes;
			}

However, when I try to pass in more than one selected diet (for example when selected = [“Vegetarian”, “Vegan”]) the results don’t change and I can tell from the results that they are not vegan. I understand that the URL has to become …&diet=vegetarian%2C+vegan … but I’m not sure how to turn my array of string into that. Thanks!

Rapid account: Spoonacular
spoonacular Commented hace 7 años

Hi, this is how you get the array to string: http://www.w3schools.com/jsref/jsref_tostring_array.asp

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입