Share:- Whatsapp Facebook Facebook

------------------------------------- Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

What is an error-first callback

0 votes
What is an error-first callback?
asked Aug 16, 2018 in Node.js by Ankush Mittal

1 Answer

0 votes
Error-first callback:- Error-first callback is used to pass an error and data. The first argument to these functions is an error object and the subsequent arguments represent associated data. So, you can check the first argument that is the error object to see if something went wrong and may be handle it. In case there is no error you can use the subsequent arguments and go ahead.

Following example of error-first callback:-

var post = new Post({title: 'test'});,calback){
     //handle error and return
  //go ahead with `calback`
answered Aug 22, 2018 by Developerhelpway (1,520 points)