Created
August 17, 2012 16:20
-
-
Save qcom/3380327 to your computer and use it in GitHub Desktop.
SyntaxError: Unexpected token
This file contains 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
// For some reason this code yields the following error upon execution: | |
// undefined: 1 | |
// | |
// ^ | |
// SyntaxError: Unexpected token | |
// Commenting out the JSON.parse() solves the error, but I don't understand what's wrong with the line | |
var fs = require('fs'); | |
var files = fs.readdirSync('./output/'); | |
var products = []; | |
for (var i = 0; i < files.length; i++) { | |
var path = './output/' + files[i]; | |
var product = JSON.parse(fs.readFileSync(path, 'utf8')); | |
products.push(product); | |
} | |
exports.products = products; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment