Encapsulate information about the outcome of an API operation and provide a standardised format for returning responses.
Create file in Utils folder¶
- Create a file name ApiResponse.js
class ApiResponse {
constructor(statusCode, data, message = "Success") {
this.statusCode = statusCode;
this.data = data;
this.message = message;
this.success = statusCode < 400;
}
}
export { ApiResponse };