1

Inside ScheduleController I call ScheduleTransformer including GroupTransformer. Inside StudentController I call StudentTransformer including GroupTransformer. GroupTransformer availableInclude schedule and students

Once started the server, in postman, I execute:

1-call schedule, return OK, then call student, return error 500.

2-restart server

3-call student, return OK, then call schedule, return error 500.

4-restant server

5-...

error 500: A transformer must be a function or a class extending TransformerAbstract

removing the include in both, no error is shown

Is this error related to some sort of "cross include"?

Windows 10.

Eduardo
  • 21
  • 3

1 Answers1

1

I figured out.

A problem or not, here what happens

If transformer A includes B and B includes A, whenever I call one of them, the second start bringing error 500 and the first continue working normally.

the simplest solution is put the importation inside the import, like this:

includeStudents(model) {

const StudentTransformer = use('App/Transformers/StudentTransformer')
return this.collection(model.getRelated('students'), StudentTransformer)

}

instead of up in the top of, as it is usual.

Eduardo
  • 21
  • 3