Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda