Skip to content

Commit

Permalink
Merge automatic scrolling into PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
aivey65 committed Aug 4, 2020
2 parents c943054 + 422d6a1 commit 21921c5
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 117 deletions.
24 changes: 16 additions & 8 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ app.get(
const minprice = "0";
const maxprice = "4";

// Try for invalid Json Response.
try {
const placesApiResponse = await (
await fetch(
Expand All @@ -278,10 +277,14 @@ app.get(
error: { type: status },
});
} else {
// Normalize undefined or null to an empty array
response.json({
status: 200,
data: placesApiResponse,
location: { latitude, longitude },
data: {
places: placesApiResponse.results || [],
attributions: placesApiResponse.html_attributions || [],
center: { latitude, longitude },
},
});
}
// Catch Fetch error
Expand All @@ -293,11 +296,13 @@ app.get(
});
}
} else {
// Respond with empty object if there is no user location.
const placesApiResponse = {};
response.json({
status: 200,
data: placesApiResponse,
data: {
places: [],
attributions: [],
center: null,
},
});
}
}
Expand Down Expand Up @@ -347,10 +352,13 @@ app.get(
getEvent,
async (request, response) => {
const { event } = request;
const users = event.users || {};
const users = Object.values(event.users || {});
response.json({
status: 200,
data: Object.values(users),
data: {
participants: users,
center: users.length > 0 ? averageGeolocation(users) : null,
},
});
}
);
Expand Down
Loading

0 comments on commit 21921c5

Please sign in to comment.