0

I want to error or response should be like

// if error accrue then 
{
 error:{
   meaage:"custome message",
   description:"custome message"
 },
 data:null,
 status:404
}
wentjun
  • 40,384
  • 10
  • 95
  • 107
  • Can you extend your question a bit and share an end-to-end description of your desired workflow? Do you have any (incomplete) example code you can share with us? – Carl in 't Veld Feb 15 '20 at 14:34

1 Answers1

0

One of the way to handle this would require looking into Loopback sequence file. There is reject sequence that you can override. Inside there you can process any error the way you like.

When you override this function and write your custom implementation you have access to handlerContext and error object. Handler context coontains request/response related data and error contains error. Based on some data from error ie: err.name = unauthorized you could have it return something like:

return {
 error:{
   meaage:"custome message",
   description:"custome message"
 },
 data:null,
 status:404
}
Rikardo
  • 79
  • 1
  • 10