Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

afterSave triggered for 'ClassName' for user undefined: #3353

Closed
newdev7 opened this issue Jan 11, 2017 · 1 comment
Closed

afterSave triggered for 'ClassName' for user undefined: #3353

newdev7 opened this issue Jan 11, 2017 · 1 comment

Comments

@newdev7
Copy link

newdev7 commented Jan 11, 2017

I tried to trigger a request inside the afterSave function in cloud code. But it throws an error like the user is undefined.

In the afterSave function, I have code like this,

Parse.Cloud.afterSave("ClassName", function(request) {
var objectId = request.object.id;
Parse.Cloud.httpRequest({
	  method: 'POST',
	  url: URL,
	  headers: {
	    headers
	  },
	  body: {
                body
          }
      }).then(function(httpResponse) {
	  console.log('ResponseText is : ' + httpResponse.text);
	}, function(httpResponse) {
	  console.error('Request failed with response code ' + httpResponse.status);
	});

It returns an error.
info: afterSave triggered for AudioFile for user undefined:
Input: {input,"createdAt":"2017-01-11T11:15:54.128Z","updatedAt":"2017-01-11T11:15:54.128Z","objectId":objected} className=ClassName, triggerType=afterSave, user=undefined
ResponseText is :

I have added Parse.Cloud.useMasterKey(); inside the afterSave function. But it returns the same error only.

Any help is much appreciated. Thanks.

@natanrolnik
Copy link
Contributor

natanrolnik commented Jan 11, 2017

@newdev7 usage of Parse.Cloud.useMasterKey(); is unavailable in Parse server, as you noted. Pass {useMasterKey: true} instead. Read more here.

Besides that, it's not an error that user is undefined, it's just an information. When no user is logged in, they can still save data, unless you enforce Class Level Permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants