I have tried below code to get indexedDb quota storage information
navigator.webkitTemporaryStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); }
);
It is not working and giving the following error.
Property 'webkitTemporaryStorage' does not exist on type 'Navigator'.
Can anyone provide solution for getting indexedDb quota storage information in typescript?
The problem lays in missing TypeScript typing. You can consider this answer.
To solve the issue, one solution is to declare the variable of type any
:
let nav: any = navigator;
nav.webkitTemporaryStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); }
);
Another way is to extend the interface of Navigator
interface Navigator {
webkitTemporaryStorage: {
queryUsageAndQuota ;
}
}
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