Unable to access afterSave Request data

Hi.

I have an afterSave function in my Cloud Code:

Parse.Cloud.afterSave(“List”, async (request) => {
let data = request.object;
console.log(“Object.keys(data) :”, Object.keys(data)); // returns [ ‘_objCount’, ‘className’, ‘id’ ]
// 1. But why? Shouldn’t it return the columns (keys) from the class "List"

var array = Object.keys(data);
for (var i = 0; i < array.length; i++) {
console.log(“value :”, await data.get(array[i])); // returns undefined
// 2. Why? How else to access the data for the object for which the afterSave function has been triggered?
});

Thanks!

You can get the request.object’s payload by using:

console.log("Object.keys(data) :", Object.keys(data.attributes))

There’s no need to use “await” for object.get("").

@dblythy Thanks for your response. That does help!
Although, request.object.attributes seems to be excluding the “objectId” field.
Is there a workaround for that?

PS: i couldn’t any information regarding “attributes” or the other solution that i found (request.object.toJSON() ) anywhere in any of the documentation. Would have saved me a day of headache. How can i or someone else add this information in the documentation as well?

Thanks again.