I make service which encoding password. this service use ts-md5:
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Md5 } from 'ts-md5/dist/md5';
@Injectable()
export class HashService {
constructor() { }
generate(str): Observable<string>{
const h = Md5.hashStr(str);
console.log(h, typeof h);
return h;
}
}
From component i subscribe to service:
this.hashService.generate(this.form.value.password).subscribe((hash) => {
console.log(hash);
});
But console display follow error message:
ERROR in src/app/shared/services/hash.service.ts(15,5): error TS2322: Type 'string | Int32Array' is not assignable to type 'Observable'. Type 'string' is not assignable to type 'Observable'
I tried to specify a more common type:
generate(str): Observable<any>{
but the problem persists