Closed LongLiveCHIEF closed 10 years ago
Need more information for when this happens?
During data returned from login.
Sent via the Samsung GALAXY S®4, an AT&T 4G LTE smartphone
-------- Original message -------- From: Justin Walrath notifications@github.com Date:02/14/2014 8:49 AM (GMT-06:00) To: NormalGravity/debate-n-go-api debate-n-go-api@noreply.github.com Cc: Brian Vanderbusch brian@2pioneers.com Subject: Re: [debate-n-go-api] Api is not returning user Id for comments (#27)
Need more information for when this happens?
— Reply to this email directly or view it on GitHub.
I pulled out the returned json from the response by opening the console at evsvillas.com with user "pqr91g" and I don't see the issue being replicated. I have 300 lines of JSON and in the section with those specific messages it is showing the id for both of them... On Feb 14, 2014 4:10 AM, "Brian Vanderbusch" notifications@github.com wrote:
I'm getting a blank object back for user inside of a posts replies. Can't display user info. I'm also getting the user object back as "users" instead:
{"users":{},"response":"here we go","postDate":{"sec":1392348024,"usec":878000}}
{"users":{},"response":"another argument with myself!","postDate":{"sec":1392370971,"usec":255000}}
Reply to this email directly or view it on GitHubhttps://github.com/NormalGravity/debate-n-go-api/issues/27 .
I think I figured out what is causing the view to not feed a user identity for the replies... it's the $id
vs id
thing again. I'm sending (and binding) to id
, but am getting $id
back from the server. Can you make the server return that key as id
? it's the key for the userid in each reply object (child of the posts object, which is a child of VotingTopic)
So I have a function to retrive usernames by id:
$scope.getUserNickname = function(user){
console.log(user);
for(var i = 0; i < $scope.users.length; i++ ){
if($scope.users[i].id === (user['$id'] || user.id))
return $scope.users[i].nickname;
}
}
However for replies, it's sending this error: TypeError: Cannot read property '$id' of undefined
. BUT, the console log shows the user
variable i'm passing IS defined:
Object {$id: "000000000000000000000001"} controllers.js:79
Object {$id: "000000000000000000000001"} controllers.js:79
Object {$id: "000000000000000000000010"} controllers.js:79
Object {$id: "000000000000000000000001"}
I think we're having problems with this for 2 reasons. $
is invalid as an object key in javascript/json, and $
is reserved by angular, and then by jquery. I think as a standard moving forward, we should avoid any i/o with keys containing special characters aside from _
ok, here's a gist with the payload received by chrome: https://gist.github.com/LongLiveCHIEF/f73a0f8c13111da7d28a
check out line:179 vs 189. why is the same object named two different things? maybe it's just leftover from old code and could just be culled from the db?
Alright, I narrowed down the issue with the $id, I'll get that sorted here in a little bit. The user/users issue I'll need to dig up. That's some of the newest code written so there isn't a "legacy" issue, it's just a straight bug.
Well that's a relief. A plain old bug. Never thought I'd see the day!
Forgot to close this when it got fixed.
I'm getting a blank object back for
user
inside of a posts replies. Can't display user info. I'm also getting the user object back as "users" instead: