Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

79
Vistas
NextJS shows a glitch on the backend side of the web application

so I'm using strapi as my backend and made a small script for authorization of some parts of the API, and added a small tweak to the controller

'use strict';
const { sanitizeEntity } = require('strapi-utils');
const finder = require('strapi-utils/lib/finder');



/**
 * Read the documentation (https://strapi.io/documentation/developer-docs/latest/development/backend-customization.html#core-controllers)
 * to customize 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 })
    }
};

And tweaked everything correctly on the front-end part, but after reloading Next, i get a

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');


Once I remove the import of SanitizeEntity the error dissappears but I need it inside the controller. I don't know why it shows a pino pretty error when I don't even use it. Or is this a weird glitch? If someone can help me I'd really appreciate it :)

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If you're using Strapi ver > 4, here's how to require it:

const { sanitizeEntity } = require('@strapi/utils');
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda