Reputation: 1892
I've this problem: I've seen that in Parse JS documentation, to retrieve a field from a Parse Object or a Parse User, I have to do this, for example: var name = currentUser.get('first_name');
. I'm using it on Express.js, the problem is that it works only if, for example, first_name
was just set in the past. If the field is empty, it doesn't retrieve anything and lock my Express app. To retrieve this user, I've made simple request:
request({
uri:'http://myapp.herokuapp.com/parse/users/me',
headers: {
'X-Parse-Application-Id': 'myAppId',
'X-Parse-Session-Token': req.session.token
},
json:true
}).then((userData) => {
if(userData){
user = Parse.Object.fromJSON(userData);
resolve(user);
}
}).catch((error) => {
reject(error);
});
and it works very well...so why does it not work? I need also to put masterKey in the request
?
Thank you
Upvotes: 1
Views: 43
Reputation: 382
Check if the problem is due to other fields, like this:
var otherJSObject = user.get('value').id;
in this case you need to see if the value exists:
var otherJSObject = user.get('value');
if(otherJSObject)
{
let id = otherJSObject.id;
}
Upvotes: 1