Reputation: 732
i m making an App with Angular 7 and i want to store the password of the users in the chrome built in a link! and i cant use it because cant create the " new PasswordCredential ".
i can check if it is availbe using '(window as any).PasswordCredential', but i cant create the instance of PasswordCredential
if ((window as any).PasswordCredential) {
const credentials = new PasswordCredential ({
name: userLogin.username,
password: userLogin.password,
});
return navigator.credentials.store(credentials);
}
the error shows 'Cannot find name 'PasswordCredential'.ts(2304)'
and in the navigator also show 'Property 'credentials' does not exist on type 'Navigator'.ts(2339)'
Upvotes: 4
Views: 1364
Reputation: 210
First you need to write:
declare global {
interface Window {
PasswordCredential: any;
FederatedCredential: any;
}
}
Then:
if (window.PasswordCredential) {
...your code here
}
Upvotes: 4