I'm trying to connect to API with my angular app and I want to create a get function that returns an array. Connecting works fine, but the function doesn't return what I want.
Here's code.
export class ApiService {
constructor(private http: HttpClient) {}
public getUsers() {
const res = this.http.get('http://localhost:3000/user');
res.subscribe(response => {
console.log(response);
return response;
});
}
}
console.log() prints an array, but when I try to do users = this.getUsers(); and console.log() it, it prints ZoneAwarePromise instead.