Skip to content

Commit

Permalink
improve error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Jan 6, 2024
1 parent 29e8064 commit 801e7c9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions app/lookup/[domain]/map/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ const MapResultsPage: FC<MapResultsPageProps> = async ({
}) => {
const markers = await Promise.all(
Object.entries(regions).map(async ([code, data]) => {
const response = await fetch(
`${
process.env.SITE_URL ||
process.env.VERCEL_URL ||
'http://localhost:3000'
}/lookup/${domain}/map/resolve/${code}?type=A&domain=${domain}`
);
const url = `${
process.env.SITE_URL ||
(process.env.VERCEL_URL && `https://${process.env.VERCEL_URL}`) ||
'http://localhost:3000'
}/lookup/${domain}/map/resolve/${code}?type=A&domain=${domain}`;
const response = await fetch(url);
if (!response.ok)
throw new Error(`Failed to fetch ${code}, ${await response.text()}`);
throw new Error(
`Failed to fetch ${url}, Status: ${
response.status
},\n\nResponse:\n${await response.text()}`
);
const results = await response.json();

return {
Expand Down

0 comments on commit 801e7c9

Please sign in to comment.