Problem could be that you were not waiting for the response here and that cause following weird problems.
You don’t need to make find and after article[0]. Make it with findOne as you did but do it with await…
I would simply do:
if (result) {
strapi.query('article').update(
{ id: params.id },
{ views: parseInt(result.views) + 1}
);
}
- Do not await for the update since it’s not required for the process (collateral action)
- Simplified. Don’t need to find the article first, update it, if the article does not exist, it will update nothing.
- If you need to control the possible error, then await the response and write later your code