I seem unable to access a particule node of the JSON object. There is a nested object (provider), but if I reference that I get undefined, or if out output to console, I should be getting the provider object, but instead it is returning
function () { [native code] }
Here is the full code I am trying to run:
OrgProvider.find( {where: { orgId: data.orgId, providertypeId: data.typeID}, include: 'provider' }, function(err, orgprovider){
console.log('orgprovider:' + JSON.stringify(orgprovider)); // outputs: the object pasted above
console.log('target value:' + orgprovider[0].provider); // outputs: function () { [native code] }
console.log('target value String:' + JSON.stringify(orgprovider[0].provider)); // outputs: undefined
data.providerId = orgprovider[0].provider.id; // returning as undefined.. can't seem to get to id
console.log('data:' + data);
callback(null, data);
});
And here is the output from that code:
orgprovider:[{"tstamp":"2018-01-02T12:50:15.009Z","id":"5a4b8007df953311190bb1bb","providerId":"5a042c973816380e7d6f4e61","orgId":"5a029ead07e76372952b4ca0","providertypeId":"2","provider":{"company”:”The Professionals","name":"Elanore”,”email":"sup...@theprofessionals.com.au","phone":"02 1234 2345","id":"5a042c973816380e7d6f4e61"}}]
target value:function () { [native code] }
target value String:undefined
data: { customerId: 5a2e1e10ed8f2194e5d7b691,
typeID: '2',
ticketStatusId: 'open',
title: 'Test Ticket',
body: 'Test ticket',
orgId: 5a029ead07e76372952b4ca0,
providerId: undefined }
I have been looking everywhere for a possible explanation to this but no luck. However there are some similar issues others have encountered in JS which appear to be related to the reference being a reserved word, but I can't find a list of reserved words for loopback.
Huge thanks in advance for any assistance with this.
Jason
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/32f513eb-b9e9-4fdf-8063-c8dc95394ad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.