1.0.4 • Published 3 years ago

api-response-formate v1.0.4

Weekly downloads
10
License
ISC
Repository
-
Last release
3 years ago

api-response-formate

api-response-formate is for simple and standard api response

Install

npm install api-response-formate
  • res - res: Response
  • code - Response status code.
  • data - response data
  • message - Message
  • error - 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