Skip to content

Can't modify response data in afterRemote #1816

@EmileSpecs

Description

@EmileSpecs

This is a very strange issue and annoying because it's just one of those that's not supposed to not work!

I have this mixin which is simply supposed to delete the password from the response data just like in the documentation:

Model.afterRemote(options.from, function(ctx, modelInstance, next) {
        if (ctx.result) {
            if (Array.isArray(ctx.result)) {
                ctx.result.forEach(function(result) {
                    delete result.password;
                    result.more = 'Add more!';
                });
            } else {
                delete ctx.result.password;
            }
        }
        console.log('Deleted password', ctx.result);
        next();
    });

The result still includes the password and the more property that I've added doesn't exist in the response data.

Interestingly if I set result.password = null; the console shows the password as null!?
So it won't delete it, it won't add a property but it will let me set it to null.

Some bug? Caching the results? Any help please, I'm pulling out my hair!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions