Build a UPC Searcher Using Node.js

Welcome to our Best Buy API in a Minute series. In this video we'll walk you through building a UPC searcher using Node.js. If you have any questions, comments or ideas for future tutorials, please drop us a line at developer@bestbuy.com.

JavaScript

var bby = require('bestbuy')();

var search = bby.products('upc=' + process.argv[2]);

search.then(processData);

function processData (data) {
  if (!data.total) {
    console.log('No products found.');
  } else {
    var product = data.products[0];
    console.log('Name:', product.name);
    console.log('Price:', product.salePrice);
  }
}