I have a function, which makes query and processes it rezult in the subscription. This function must return 200 if query was successful or error codes in other cases. What I need to do to return value I got in the subscription?
public loginEmail(email: string, password: string): Subscription {
return this.http.post < any > (`http://127.0.0.1:8080/user/`, {}, {
params: new HttpParams().set('email', email).set('password', password)
})
.subscribe(resp => {
console.log(resp);
this.user.setUser(resp['user'])
return 200;
}, error => {
return error.code
});
}