README
api-response-formate
api-response-formate is for simple and standard api response
Install
npm install api-response-formate
res
- res: Responsecode
- Response status code.data
- response datamessage
- Messageerror
- error object
cosnt response =require('api-response-formate');
cosnt test=(req,res,next)=>{
try{
return response(res,200,'my data','success',null)
/**
API response will be --
{code: 200, data:'my data' ,message:'succsess',error:null}
*/
}catch(error){
return response(res,402,null,'Something went wrong..!',error);
/**
API response will be --
{code: 402, data:null,message:'Something went wrong..!',error: error object}
*/
}
}
module.exports=test