From 01dd22fda8c5dd00242f60bb12241336cb382ce3 Mon Sep 17 00:00:00 2001 From: cyprain-okeke <108260115+cyprain-okeke@users.noreply.github.com> Date: Wed, 20 Jul 2022 20:21:13 +0100 Subject: [PATCH] Ps 971/rate limiting error gives html (#3097) * made changes in the errorResponse.ts to return toast message for status 429 * refactor the existing bug implementation Co-authored-by: dynwee --- libs/common/src/models/response/errorResponse.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/common/src/models/response/errorResponse.ts b/libs/common/src/models/response/errorResponse.ts index 3a0d22e695d..859803b441f 100644 --- a/libs/common/src/models/response/errorResponse.ts +++ b/libs/common/src/models/response/errorResponse.ts @@ -21,15 +21,13 @@ export class ErrorResponse extends BaseResponse { } } - if (errorModel) { + if (status === 429) { + this.message = "Rate limit exceeded. Try again later."; + } else if (errorModel) { this.message = this.getResponseProperty("Message", errorModel); this.validationErrors = this.getResponseProperty("ValidationErrors", errorModel); this.captchaSiteKey = this.validationErrors?.HCaptcha_SiteKey?.[0]; this.captchaRequired = !Utils.isNullOrWhitespace(this.captchaSiteKey); - } else { - if (status === 429) { - this.message = "Rate limit exceeded. Try again later."; - } } this.statusCode = status; }