Hello,
Is there any way to view request.object json key values with logger.info or other logging methohds
Logger.info just return [object Object] for objects.
Thanks,
Hello,
Is there any way to view request.object json key values with logger.info or other logging methohds
Logger.info just return [object Object] for objects.
Thanks,
This code will print John in logger when called
const myJSON = '{"name":"John"}';
const myObj = JSON.parse(myJSON);
x = myObj.name;
logger.info(x)
you can always use something like logger.info(JSON.stringify(object))
It is not working unfortunately
Did you get any error?
Logger.info(JSON.stringify(object)) this return just undefined.
Also I tried a lot of version of JSON.parse method. But it is sometime returned afterSave caught an error Unexpected.
I can acces variable in json with that method,
const state = request.object.get(βstateβ);
That is working properly.
But I need to see all json data. Any debugging method or logging method for json data can be more helpful
Thanks,
With logger.info(JSON.stringify('{"Name":"John", "Pet": "Dog"}'))
you should see something like this.
and with
const myObj = JSON.parse('{"Name":"John", "Pet": "Dog"}');
x = myObj.Name;
y = myObj.Pet;
logger.info(x);
logger.info(y);
you should get something like this
can you share your afterSave function
@johnversus thank you,
I tried as below and it worked
Moralis.Cloud.afterSave("Race", async (request) => {
const obj = JSON.stringify(request.object)
const myObj = JSON.parse(obj);
x = myObj.objectId;
logger.info(x);
});