Hello,

iin loginIn you do not return anything. And you already subscribe to the 
observable.
So in the app you try to call subscribe to an empty type. I would use 
something more like this which returns an observable:
to log in() {
return this._http.get <Login []> (this._url) .pipe (
tap (data => {this.dataStore.next (data);
console.log ("loginIn: =>" + this.dataStore);
this._route.navigate (['/ home'])
})
);
}

There are other errors but I think that they are due to the model: that is 
to say: _url is not a URL but a json object (incorrect).

I'm not sure if this is the best place to call route._navigate, either move 
them to the final subscriptions, or better use a route guard:
https://angular.io/guide/router#canactivate-requiring-authentication

I hope this will help you,
Regards,
Arnaud.

On Monday, 30 March 2020 16:06:20 UTC+2, learningA wrote:
>
> Hello,
>
> I been trying to understand the topic of *BehaviorSubject & Observable* 
> by using a simple login application with no success and I'm wondering if 
> someone can look at the code and let me know what aim doing wrong. I been 
> at it for a month with no success.
>
> Angular project
> stackBlitz: https://stackblitz.com/edit/angular-qmokve
>
>
> what i have in my services
>
>  loginIn() {   
>         this._http.get<Login[]>(this._url) 
>             .map(data => this.members == data) \\does work
>             .subscribe(data => { this.dataStore.next(data);
>            console.log("loginIn:=> "+ this.dataStore);
>            this._route.navigate(['/home']);
>         }
>       );
>      
>            
>     }
>
>
> app
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/a693a05e-90e3-4405-a38f-2c134964bfb8%40googlegroups.com.

Reply via email to