Skip to content

Commit d8b91fe

Browse files
gregbilletdeauxGregadeauxthetaPC
authored
fix(angular-getting-started): type errors (#2688)
Co-authored-by: Greg Billetdeaux <gregadeaux@gmail.com> Co-authored-by: Maria Hutt <maria@ionic.io>
1 parent 1ff738a commit d8b91fe

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

docs/angular/your-first-app/4-loading-photos.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ With the photo array data saved, create a function called `loadSaved()` that can
3535
```tsx
3636
public async loadSaved() {
3737
// Retrieve cached photo array data
38-
const photoList = await Preferences.get({ key: this.PHOTO_STORAGE });
39-
this.photos = JSON.parse(photoList.value) || [];
38+
const { value } = await Preferences.get({ key: this.PHOTO_STORAGE });
39+
this.photos = (value ? JSON.parse(value) : []) as UserPhoto[];
4040

4141
// more to come...
4242
}

docs/angular/your-first-app/5-adding-mobile.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ Next, head back over to the `loadSaved()` function we implemented for the web ea
9393
```tsx
9494
public async loadSaved() {
9595
// Retrieve cached photo array data
96-
const photoList = await Preferences.get({ key: this.PHOTO_STORAGE });
97-
this.photos = JSON.parse(photoList.value) || [];
96+
const { value } = await Preferences.get({ key: this.PHOTO_STORAGE });
97+
this.photos = (value ? JSON.parse(value) : []) as UserPhoto[];
9898

9999
// Easiest way to detect when running on the web:
100100
// “when the platform is NOT hybrid, do this”

versioned_docs/version-v6/angular/your-first-app/4-loading-photos.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ With the photo array data saved, create a function called `loadSaved()` that can
3636
public async loadSaved() {
3737
// Retrieve cached photo array data
3838
const photoList = await Preferences.get({ key: this.PHOTO_STORAGE });
39-
this.photos = JSON.parse(photoList.value) || [];
39+
this.photos = (value ? JSON.parse(value) : []) as UserPhoto[];
4040

4141
// more to come...
4242
}

versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Next, head back over to the `loadSaved()` function we implemented for the web ea
9494
public async loadSaved() {
9595
// Retrieve cached photo array data
9696
const photoList = await Preferences.get({ key: this.PHOTO_STORAGE });
97-
this.photos = JSON.parse(photoList.value) || [];
97+
this.photos = (value ? JSON.parse(value) : []) as UserPhoto[];
9898

9999
// Easiest way to detect when running on the web:
100100
// “when the platform is NOT hybrid, do this”

0 commit comments

Comments
 (0)