tbx-response
v1.0.0
Published
An HTTP API response body builder with JSend format https://labs.omniti.com/labs/jsend
Downloads
2
Readme
What is tbx-response?
tbx-response is a response body builder for HTTP API response by using JSend Format
Feature
tbx-response featuring 4 type of responses:
- Success Response A normal successful response with existing data/payload
{
status: "success",
data: <your data/payload>
}
- Empty Response An empty response where the data requested is not exist
{
status: "empty",
data: []
}
- Fail Response A fail response where there is a problem with incoming request
{
status: "fail",
data: <the problem>
}
- Error Response An error response where there is an error occured when processing the request
{
status: "error",
message: <error message>
}
Installation
$ npm install tbx-response
or
$ npm install --save tbx-response
Usage
var tbx = require('tbx-response');
// Create success response body
tbx.createSuccessBody(data);
// Create empty response body
tbx.createEmptyBody();
// Create fail response body
tbx.createFailBody(data);
// Create error response body
tbx.createErrorBody(message);