Hi,
since updating my environment my project seems to be completey broken, and I dont know if I ever get my project working again. I used e.g. a simple storage class, but now I get errors.
Error: src/app/services/storage.service.ts:17:5 - error TS2322: Type 'GetResult' is not assignable to type '{ value: string; }'.
Types of property 'value' are incompatible.
Type 'string | null' is not assignable to type 'string'.
Type 'null' is not assignable to type 'string'.
17 return (await Preferences.get({ key }));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: src/app/services/storage.service.ts:26:23 - error TS2345: Argument of type 'string | null' is not assignable to parameter of type 'string'.
Type 'null' is not assignable to type 'string'.
26 return JSON.parse(ret.value);
In my real app I actually use option 2, but what confused me is the GetResult.value: string hint, and thought I was getting a string back here directly.
I must admit that I have not yet fully understood this Promise issue.
Hey there, I know it’s an older subject but since it talks about preferences, I thought it would be a good place. I’m getting the preferences API (@capacitor/preferences) to work on the web. But when I use the iOS emulator, it’s not working. I don’t see the same result as in the web version.
I cannot figure why, and I can’t find any log about the problem in the emulator.
Thanks for the help! So the problem was that I was storing the data as a boolean, it works on the web but not on iOS. The value was cast and stored as a string on the web, but it was just not working on iOS.