I read about this awesome feature in RXJS which would theoretically allow me to subscribe only for one response, but can't seem to implement it. Instead, I'm getting this error,
"Property 'first' does not exist on type 'Observable'."
although I am just copy-pasting from existing examples. Here's my code:
implementHash( token ){
console.log('trying to implement hash', token);
const req = this.http.get('http://localhost:3003/token/' + token );
const sub = req
//.first()
.subscribe( res =>{
sub.unsubscribe; // trying to avoid this line
});
};
You need to
import 'rxjs/add/operator/first'
;
in your file.
Add import 'rxjs/add/operator/first'
to your component.ts file.
It comes from the import first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With