Inverse-Rezeptsuche/application/static/main.js

27 lines
656 B
JavaScript
Raw Normal View History

2020-04-10 14:14:34 +00:00
2020-04-18 12:56:22 +00:00
rl = document.getElementById("recipe-list")
2020-04-10 14:14:34 +00:00
function loadData() {
2020-04-18 12:56:22 +00:00
searchString = document.getElementById("search-field").value
searchArray = searchString.split(',');
getParams = ""
searchArray.forEach(
function(item, index){
if (index > 0){
getParams += "&ingred=" + item.trim()
}
else{
getParams += "?ingred=" + item.trim()
}
});
console.log(getParams)
getJSON("/api/v1/recipe/"+getParams,
2020-04-10 14:14:34 +00:00
function (error, data) {
2020-04-18 12:56:22 +00:00
data = data["data"] // remove wrapper
console.log(data)
2020-04-10 14:14:34 +00:00
},
null
);
}