My find Ingredient function gets 1 argument which i pass to my GET api. When I only console log my result.body I get undifined.
So I looked it up and i need to use callback in my .end function. But when I do, it returns an error: Callback does not exist on type void
findIngredient(searchTerm: HTMLInputElement) {
this.unirest.get('https://spoonacular-recipe-food-nutrition-
v1.p.mashape.com/recipes/' +
'findByIngredients?fillIngredients=false&ingredients='
+ searchTerm.value + '&limitLicense=false&number=5&ranking=1')
.header('X-Mashape-Key', 'key1')
.header('X-Mashape-Host', 'host1')
.end(function (result) {
const data = result.body.data;
if (!result.error && result.statusCode === 200) {
callback(null, data);
} else {
console.log('Failed response', result.error)
.callback(result.error, null);
}
});
}