Answer the question
In order to leave comments, you need to log in
How to return a DB response in AngularJS?
Good afternoon. Wrote a function for a service in AngularJS that makes a request to the database. I can't figure out how to make the function return the data value. In my case below, the value is undefine, which is logical because not the function itself, but the resolved request promise returned data. How to correctly change the function, so that as a result it itself would return data. Thanks in advance.
function getData($http) {
this.users = function(){
$http.get('http://localhost:3000/getUsers')
.success(data=>{
return data})
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question