Browse Source

Bug fix: updating merchant address was hanging the site.

Lee Morgan 5 years ago
parent
commit
68073fbcbb
1 changed files with 6 additions and 1 deletions
  1. 6 1
      controllers/merchantData.js

+ 6 - 1
controllers/merchantData.js

@@ -273,7 +273,12 @@ module.exports = {
             mailgun.messages().send(mailgunData, (err, body)=>{});
         }
 
-        if(req.body.address !== "", req.body.address.toLowerCase() !== res.locals.merchant.address.full.toLowerCase()){
+        if(req.body.address !== "" && 
+            (
+                res.locals.merchant.address.full === undefined ||
+                req.body.address.toLowerCase() !== res.locals.merchant.address.full.toLowerCase()
+            )
+        ){
             let baseURL = "https://geocoding.geo.census.gov/geocoder/locations/onelineaddress/";
             let address = req.body.address.replace(/ /g, "+");
             let geocode = await axios.get(`${baseURL}?address=${address}&benchmark=2020&format=json`);