ActionSuccess và ActionError
- Sử dụng
ActionSuccess
thay thế chojson
trong remix khi trả về kết quả thành công choaction
export class ActionSuccess<T> {
payload: T;
success = true;
constructor(data: T) {
this.payload = data;
}
}
- Sử dụng
ActionError
thay thế chojson
trong remix khi trả về kết quả lỗi choaction
export interface FieldError {
field: string;
message: string;
}
export class ActionError {
message: string;
errors: FieldError[];
success = false;
constructor(message?: string, errors?: FieldError[]) {
this.message = message || 'Bad Request';
this.errors = errors || [];
}
}