Skip to content

Commit

Permalink
fix: adds optional chaining for fixing wrong api responses
Browse files Browse the repository at this point in the history
  • Loading branch information
migtarx committed Jul 29, 2024
1 parent 6fb7842 commit 9dbb3b4
Show file tree
Hide file tree
Showing 2 changed files with 814 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ app.use(async function getLocation(req, res, next) {
data = await ffclient.getIpData(ip);
} catch (error) {
console.error('Error fetching IP location:', error);
ipData = { country_name: 'Unknown || Error fetching' };
ipData = { country_name: 'Unknown || Error fetching', city: 'Unknown || Error fetching' };
}
req.location = `${ipData.data.city}, ${ipData.data.country_name}`;
req.location = `${ipData?.city}, ${ipData?.country_name}`;
next();
});

Expand Down
Loading

0 comments on commit 9dbb3b4

Please sign in to comment.