Skip to main content

ActionSuccess và ActionError

  • Sử dụng ActionSuccess thay thế cho json trong remix khi trả về kết quả thành công cho action
export class ActionSuccess<T> {
payload: T;
success = true;
constructor(data: T) {
this.payload = data;
}
}
  • Sử dụng ActionError thay thế cho json trong remix khi trả về kết quả lỗi cho action
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 || [];
}
}