i have code :
router.get('/pincode/:pincode',function(req, res) { Pincode.find({pincode : req.params.pincode}, function(error,pincode ) { if(pincode == '' var request = require('request'); console.log(); res.statusCode = 302;
request('http://postalpincode.in/api/pincode /'+req.params.pincode,function (error, res, body) { if (res.statusCode === 200) { var pincodeData = new Pincode({ pincode:req.params.pincode, body:body.PostOffice.Name }); pincodeData.save(function (err,results) { if (err) { return err; } else { console.log(body); } }); } }); } res.json(pincode); });
});
via Poonam
No comments:
Post a Comment