I have recently made a search for my app built in ionic which is pulling from an api using a http get method as below
static get parameters() {
return [[Http]];
}
searchRecipes(id) {
var url = 'http://api.yummly.com/v1/api/recipes?_app_id=/////&_app_key=//////&q=' + encodeURI(id);
var response = this.http.get(url).map(res => res.json());
return response;
}
So far I have the id which is what they user types in. I now want to add filters to my search (ingredients, cuisine and allergies), this is done by extending the url further with specific calls such as &allowedAllergy[] and allowedDiet[].
I currently have a list of items implemented such as, each would have a value set to them, and on click on one it will add to the url provided. Implementation to be the same as http://www.yummly.uk/
<div class="diets">
<ul>
<li>Lacto vegetarian</li>
<li>Ovo vegetarian</li>
<li>PaleoPescetarian</li>
<li>Vegan</li>
<li>Vegetarian</li>
</ul>
</div>
<div class="allergies">
<ul>
<li>Dairy-Free</li>
<li>Egg-Free</li>
<li>Gluten-Free</li>
<li>Peanut-Free</li>
<li>Seafood-Free</li>
<li>Sesame-Free</li>
<li>Soy-Free</li>
<li>Sulfite-Free</li>
<li>Tree Nut-Free</li>
<li>Wheat-Free</li>
</ul>
</div>
Search Method
recipes: any;
searchRecipeDB(event, key) {
if(event.target.value.length > 2) {
this.apiAuthentication.searchRecipes(event.target.value).subscribe(
data => {
this.recipes = data.matches;
console.log(data);
},
err => {
console.log(err);
},
() => console.log('Recipe Search Complete')
);
}
}
If anyone can give advice on how to implement this it would be a life saver! Thanks all