Currently, I am utilizing Strapi for my backend and have created a small script to handle authorization for specific parts of the API. Additionally, I made a slight modification to the controller.
'use strict';
const { sanitizeEntity } = require('strapi-utils');
const finder = require('strapi-utils/lib/finder');
/**
* Refer to the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers)
* for customizing this controller
*/
module.exports = {
async find(ctx){
const { user } = ctx.state;
let entities;
if(ctx.query._q){
entities = await strapi.services.order.search({...ctx.query, user: user.id});
} else {
entities = await strapi.services.order.find({...ctx.query, user: user.id});
}
return entities.map(entity => sanitizeEntity(entity, { model: strapi.models.order }));
},
async findOne(ctx){
const {id} = ctx.params;
const {user} = ctx.state;
const entity = await strapi.services.order.findOne({id, user: user.id});
return sanitizeEntity(entity, { model: strapi.models.order });
}
};
I have successfully adjusted everything on the frontend part, but upon reloading Next, an error occurs:
Unhandled Runtime Error
TypeError: pino.pretty is not a function
Source
../ecomm-backend/api/order/controllers/order.js (2:27) @ eval
1 | 'use strict';
> 2 | const { sanitizeEntity } = require('strapi-utils');
If I remove the import of SanitizeEntity, the error disappears. However, it is essential for me to include it in the controller. I am perplexed as to why a pino pretty error is showing when I am not even using it. Could this be a strange glitch? If anyone can offer assistance, I would greatly appreciate it :)