Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chungweileong94/js-response
https://github.com/chungweileong94/js-response
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/chungweileong94/js-response
- Owner: chungweileong94
- Created: 2020-08-23T07:13:14.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T02:57:17.000Z (about 4 years ago)
- Last Synced: 2024-04-27T16:45:56.410Z (7 months ago)
- Language: TypeScript
- Size: 73.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-response
[![npm version](https://badge.fury.io/js/js-response.svg)](https://badge.fury.io/js/js-response)
## Success Response
```
import {successResponse} from 'js-response';...
const data = 'Hello, World!';
const meta = {}; // optionalconst response = successResponse(data, meta);
console.log(response)
```### Output
```
{
success: true,
data: 'Hello, World!',
meta: {},
}
```---
## Error Response
```
import {errorResponse} from 'js-response';...
const errorCode = 'E100';
const errorMessage = 'Error occur...';const response = errorResponse(errorCode, errorMessage);
console.log(response)
```### Output
```
{
success: false,
error: {
code: 'E100',
message: 'Error occur...'
},
}
```