node-premailer icon indicating copy to clipboard operation
node-premailer copied to clipboard

SyntaxError: Unexpected token I in JSON at position 0

Open besserwisser opened this issue 8 years ago • 5 comments

I don't know what to do against this issue. It seems like I MOST OF THE TIMES get a broken JSON from node-premailer? I am always using the same parameters including URL, but most of the times I get the error message and 1 out of 5 times, the result variable contains the result. Does anybody else have this problem?

This is how I execute it:

 premailer.prepare({ html: resBody }, function (err, result){
   console.log(results) //undefined
})

And this is the error I get:

SyntaxError: Unexpected token I in JSON at position 0 at JSON.parse () at Request.handlePremailerResponse [as _callback] (/home/pi/newsfire/node_modules/premailer-api/premailer.js:103:23) at Request.self.callback (/home/pi/newsfire/node_modules/request/request.js:186:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/home/pi/newsfire/node_modules/request/request.js:1081:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (/home/pi/newsfire/node_modules/request/request.js:1001:12) at Object.onceWrapper (events.js:290:19) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) drin /home/pi/newsfire/lib/newsfire.js:114 html: result.html // html body ^

TypeError: Cannot read property 'html' of undefined at model.Query.PageLog.find.sort.limit.find (/home/pi/newsfire/lib/newsfire.js:114:29) at /home/pi/newsfire/node_modules/kareem/index.js:264:21 at /home/pi/newsfire/node_modules/kareem/index.js:127:16 at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9)

besserwisser avatar Jan 31 '17 01:01 besserwisser

Yup, same here:

err.stack "SyntaxError: Unexpected token I in JSON at position 0 at Object.parse (native) at Request.handlePremailerResponse [as _callback] (z:\xxxx\node_modules\premailer-api\premailer.js:103:23) at Request.self.callback (z:\xxxx\node_modules\request\request.js:200:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (z:@dev\Shipatron\node_modules\request\request.js:1067:10) at emitOne (events.js:101:20) at Request.emit (events.js:188:7) at IncomingMessage. (z:\xxxx\node_modules\request\request.js:988:12) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickDomainCallback (internal/process/next_tick.js:122:9)"

Stumblor avatar Nov 13 '17 16:11 Stumblor

For me this was a stylesheet include that couldn't be resolved. Once I had corrected that, it was fine.

Stumblor avatar Nov 13 '17 16:11 Stumblor

Started getting this myself suddenly. No files have changed from working for months, has there been an NPM update that broke this?

jesper-bylund avatar Feb 06 '18 09:02 jesper-bylund

Even the example-template in the repo returns this error!

jesper-bylund avatar Feb 06 '18 10:02 jesper-bylund

Server is returning " Internal server error"

jesper-bylund avatar Feb 06 '18 10:02 jesper-bylund