in web-app/app/controllers/searchControllers.js [24:66]
function checkForSearchResults() {
// poll every few seconds for new search results i.e. matches
poll = $interval( () => {
// placeholder, no need yet for params for API call
let params = {
ApiCallType: "check-search-results"
}
$http.post(ENV + 'matches', params)
.then(
// backend responded successfully
function(response) {
console.log(response);
let rawResult = response.data.body;
rawResult = rawResult.replace(/\'/g, "\"");
let json = JSON.parse(rawResult);
$scope.searchResults = json;
$scope.images = [];
$scope.titles = [];
let matches = json.matches;
matches.forEach( match => {
$scope.images.push(match.url);
$scope.titles.push(match.title);
});
},
// failure outside the backend function, e.g. couldn't call the backend
function(response) {
$scope.stop();
console.log(response);
}
);
}, 10000); // end poll
}