api-response-formate

1.0.4 • Public • Published

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

Package Sidebar

Install

npm i api-response-formate

Weekly Downloads

4

Version

1.0.4

License

ISC

Unpacked Size

1.42 kB

Total Files

3

Last publish

Collaborators

  • namenotfound