Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

82
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!