I am just starting getting into Angular 7. I am trying to place a call to an API that resides on another domain. For that I have added all the needed headers to the API's response. Seems like I am not getting CORS error anymore. But I also dont get into results of my call. Here is some relative code: API:
getUser() {
return this.http.get<User[]>('http://localhost:98/user/settings/getuser');
}
API call:
test() {
this.userService.getUser().pipe(first()).subscribe(users => {
console.log(users);
});
}
I am not getting to this code: console.log(users); The Console shows: ERROR OK
Please help. Thanks
first()? Also check the network tab of your browser what it returns?.pipe(first()). it's implied withhttp.get(). Also, you can pass a second callback tosubscribe(users => ..., err => ...)to catch any errors. Maybe try that and see what you can log. Lastly I would check the network tab to see if your request is going through.