I tried to implement an afterFindOne lifecycly-hook but I always get the success false.
I tried the following code:
module.exports = {
lifecycles: {
async afterFindOne(result, params, populate) {
const article = strapi.query('article').findOne({ id: result.id });
console.log('das ist ein test');
console.log(article);
await strapi.query('article').update(
{ id: article.id },
{ views: parseInt(article.views) + 1 }
);
}
}
};
Do you have any idea how to solve this problem?
When I try it with fix values in the update part (for example with id 1 and views 15) it works, so it seems that the query.findOne is not working correctly. Or does this hook produces an infinite loop?
Unfortunately I don’t know how to see console.log output in postman for test/debug.
Thanks for your help!
Best regards,
Timo