Enonic version: 6.8.0
OS: macOS Sierra 10.12.1
Hey,
for the first time I am trying to modify an item from outside the admin.
I am trying to post to a controller and have it modify an item in my “Store” content type.
Everything looks like it’s working, but the item isn’t modified with my data.
exports.post = req => {
let data = JSON.parse(req.params.data);
let result = contentLib.modify({
key: data._id,
editor: c => {
editor(c, data);
}
});
return {
body: result ? JSON.stringify({ 'status': 'success', 'result': result }) : JSON.stringify({ 'status': 'error' }),
contentType: 'application/json'
};
};
function editor(c, data) {
c.data = data.data;
log.info(JSON.stringify(c));
return c;
}
The log.info in the editor(c, data) function logs out the item exactly as I want it, and the body then returns status = “success”, and the item without the modifications.
What am I missing? Do I need to, I don’t know, “commit” or “save” for it to actually modify the item? Or am I doing this totally wrong?
Thanks in advance,
Stefan