Created
October 24, 2015 16:06
-
-
Save clarle/b8a096311e33cbda8c61 to your computer and use it in GitHub Desktop.
Revisions
-
clarle created this gist
Oct 24, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ var _ = require('lodash'), express = require('express'), request = require('request'), app = express(); var API_KEY = '1Kfdqvy6wHmvJ4LDyAVOl7saCBoKHcSb'; app.get('/products/:id', function(req, res) { var ourData = { age_group: '0-1 years old', tags: ['math', 'problem solving', 'counting'] }; var id = req.params.id; request.get('http://api.target.com/items/v3/' + id, { qs: { id_type: 'dpci', key: API_KEY }, json: true }, function(err, response, body) { var targetItems = _.get(body, 'product_composite_response.items'); ourData.urls = targetItems.map(function(item) { return item.data_page_link; }); res.json(ourData); }); }); app.listen(5000); console.log('App running on port 5000');