I have to import content for Json url in other site. (its almost more than 100K content)
here code i use (i am using requset for download josn file, and mongodb for saving data)
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var content = JSON.parse(body);
// ....
}
})
Everything work well but after 50K content imoprted i got this error
SyntaxError: Unexpected token <
at Object.parse (native)
at Request._callback (/home/app/app.js:58:30)
at Request.self.callback (/home/app/node_modules/request/request.js:360:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/app/node_modules/request/request.js:1202:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/app/node_modules/request/request.js:1150:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)
i will be appreciated if tell where i am wrong.
Malformed JSON, now i just need to know how i can prevent node from exiting my app