Skip to content

Commit

Permalink
Add last comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skantus committed Apr 11, 2020
1 parent b4adb7d commit b45dc59
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function httpRequest(
headers: Headers;
body: string;
} = {method, headers, body};
let response = await fetch(url, options);
const response = await fetch(url, options);
if (response.status === UNAUTHORIZED) {
throw new Error('Error 401: unauthenticated user');
}
Expand Down
2 changes: 2 additions & 0 deletions src/api/AlbumProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ class AlbumProvider extends React.Component<Props> {
const realm = await Realm.open(photoDetailOptions);
let photos: CardItem[] = [];

// get the data from local database
photos = realmObjectsToJson(realm.objects(PHOTO_DETAIL_SCHEMA));
if (photos?.length > 0) {
this.setState({photos, realm});
return;
}

// get the data from remote server
photos = await API.get({url: `${BASE_API}${PHOTOS_URL}`});
realm.write(() => {
photos?.map((item: CardItem) => {
Expand Down

0 comments on commit b45dc59

Please sign in to comment.