Skip to content

Commit

Permalink
Handle empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansick committed Apr 12, 2024
1 parent 570c660 commit 2431df7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions apps/squareone/src/hooks/useTimesSquarePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ const fetcher = (...args) => fetch(...args).then((res) => res.json());
function useTimesSquarePage() {
const { tsPageUrl } = React.useContext(TimesSquareUrlParametersContext);
const { data, error } = useSWR(tsPageUrl, fetcher);
console.log(data);

const githubInfo = {
owner: data.github.owner ? data.github.owner : null,
repository: data.github.repository ? data.github.repository : null,
sourcePath: data.github.source_path ? data.github.source_path : null,
sidecarPath: data.github.sidecar_path ? data.github.sidecar_path : null,
};
const githubInfo = data
? {
owner: data.github.owner ? data.github.owner : null,
repository: data.github.repository ? data.github.repository : null,
sourcePath: data.github.source_path ? data.github.source_path : null,
sidecarPath: data.github.sidecar_path ? data.github.sidecar_path : null,
}
: {};

return {
error: error,
Expand Down

0 comments on commit 2431df7

Please sign in to comment.