ecresult
v1.0.14
Published
An easy way to format API result
Downloads
5
Readme
ecResult
An easy way to format API result
Install
npm install ecresult
Use
Generate Result
const ecresult = require('ecresult');
var result = new ecresult();
result.setResult(1);
result.setMessage('Hello World');
result.setData({content: "Yo"});
Generate Result with error code
const ecresult = require('ecresult');
var result = new ecresult();
result.setErrorCode('10001')
result.setMessage('Something wrong');
Generate Result with error
const ecresult = require('ecresult');
var result = new ecresult();
var error = new Error('Another thing wrong');
error.code = '10002';
result.setError(error);
Output Result
const ecresult = require('ecresult');
var result = new ecresult();
result.setResult(1);
result.setMessage('Hello World');
result.setData({content: "Yo"});
var data = result.toJSON();