I try to get a doc from firestore and send to the client the result by the object. But the result value is null. How can I get a proper return object?
// sending results from the server
db.collection("devices")
.doc(data.id)
.get()
.then((res) => {
console.log(res.data().online);
if(res.exists()){
return {
'success': true,
'online': res.data().online
};
}
else{
return {
'success': false,
'message': 'Could not find doc.'
};
}
})
// received data
const getOnlineState = async (device) => {
const response = await readState(device)
console.log(response);
};
// console
{data: null}data: null[[Prototype]]: Object
I want to see the return object.