Trying to get a single object returned by request using callbacks.
Error:undefined Data:[object Object] Why are there two objects being returned when I am returning only one error and one object?
Trying to get a single object returned by request using callbacks.
Error:undefined Data:[object Object] Why are there two objects being returned when I am returning only one error and one object?
Actually, there is only one object being returned from the callback. The reason why [object Object]
is printed, is because that is the default serialization of an object.
You can see this answer for a detailed explanation:
what does [object Object] mean?
To print the data contained in the object, you can JSON.stringify
it like this:
console.log("Data:"+JSON.stringify(data))