[SOLVED] Cannot read properties of undefined (reading 'set')

Getting this error with my cloud function

Error: {“message”:“Cannot read properties of undefined (reading ‘set’)”,“code”:141}

Moralis.Cloud.define("createAvatar", async (request) => {

	const logger = Moralis.Cloud.getLogger();
	logger.info("Request coming 6: " + JSON.stringify(request));

	logger.info("User : " + JSON.stringify(request.user));

	request.user.set("username", "new_usernname");
	await request.user.save(null, {useMasterKey: true});

	return request.user;

}, {
	fields: ['name', 'gender']

are you authenticated when you run this function?

1 Like

wow Im a noob… wasnt authenticated! haha its working now, thank you!

1 Like