Created
November 1, 2014 12:54
-
-
Save chaitu87/9a1c3d817f27002fd7b2 to your computer and use it in GitHub Desktop.
vendor controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'), | |
router = express.Router(), | |
request = require('request'), | |
hull = require('hull'); | |
hull.conf({ | |
appId: 'xxxx', | |
orgUrl: 'xxxx', | |
appSecret: 'xxxx' | |
}); | |
var client = hull.client(); | |
module.exports = function (app) { | |
app.use('/', router); | |
}; | |
router.get('/:slug', function (req, res, next) { | |
// res.send(req.params.slug); | |
var path = 'http://fitn.in/finderdetail/'+req.params.slug; | |
request(path, function (error, response, body) { | |
if (!error && response.statusCode == 200) { | |
// console.log(response.body); | |
// Read Hull Reviews | |
//var encoded = Hull.utils.entity.encode('vendor123456')+'/reviews'; | |
client.get(encoded,{},function(data){ | |
var allreviews = data | |
}); | |
var data = JSON.parse(body); | |
res.render('vendor', { | |
vendor: data, | |
reviews: allreviews | |
}); | |
}else{ | |
res.send("Not found"); | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment