I'm at my rope's end on this one. I am getting this error in seemingly random places in my app. Raven reports them from a couple dozen locations but I can only replicate a couple locally. It seems to me that the problem has something to do with the parsing of the JSON response but the responses are valid.
In my Angular service...
...
getThread: function(id, success, error) {
$http.get('/message/'+id).success(function(data){
success(data);
}).error(error);
}
...
In my Express controller...
...
res.json(mssgs);
...
Here's a sample response...
[
{
"id": 79,
"body": "test",
"senderArchived": false,
"recipientArchived": false,
"createdAt": "2014-04-17T01:44:46.762Z",
"updatedAt": "2014-04-17T01:44:46.762Z",
"RootMessageId": 69,
"SenderId": 164050,
"RecipientId": 154040,
"sender": {
"username": "boca",
"id": 164050,
"primaryMedium": null
},
"recipient": {
"username": "quimby",
"id": 154040,
"primaryMedium": {
"id": "186",
"type": "image",
"nativeURL": "https://domain/imageurl.jpg",
"mediumURL": "https://domain/imageurl.jpg",
"smallURL": "https://domain/imageurl.jpg",
"createdAt": "2014-04-21T15:52:10.927Z",
"updatedAt": "2014-04-21T15:52:10.947Z",
"CommentId": null,
"EventId": null,
"UserId": 154040,
"PostId": null,
"MessageId": null,
"MediaFolderId": null
}
},
"messageMedia": []
}
]
In both Chrome and Safari this results in error "Uncaught SyntaxError: Unexpected token )"
Here's the request headers from Chrome...
Remote Address:127.0.0.1:3001
Request URL:https://localhost:3001/message/69
Request Method:GET
Status Code:200 OK
Request Headers
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,ja;q=0.6
Connection:keep-alive
Cookie:streamLoc=%7B%22distance%22%3A-1%2C%22locName%22%3A%22%22%7D; usePostLocation=yes; connect.sid=s%3AhX37rupUct2jut4yApN1GIH9.n5nPURTMXl5OKd46rMqeRc4bg1Q%2F%2Bky0El2r%2BcBvC8c; user=%7B%22id%22%3A154040%2C%22role%22%3A%7B%22bitMask%22%3A32%2C%22title%22%3A%22admin%22%7D%2C%22username%22%3A%22quimby%22%2C%22emailVerified%22%3Atrue%2C%22verified%22%3Atrue%7D
Host:localhost:3001
Referer:https://localhost:3001/messages
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
Response Headers
Connection:keep-alive
Content-Length:1115
Content-Type:application/json; charset=utf-8
Date:Tue, 29 Apr 2014 02:41:47 GMT
ETag:"485872145"
X-Powered-By:Express
Every other similar question has pointed to JSONP or actual syntax problems but I'm not using JSONP and there are not any code syntax problems.
errorargument in your.error()call a function? Edit: Never mind, I see it. You're passing in callbacks to thegetThreadfunction. Can you post the code for your success and error functions? There may be a syntax issue there, who knows.