From d1504f2ae19816b3fadcdb3ad17facc863ed7529 Mon Sep 17 00:00:00 2001 From: Khafra <42794878+KhafraDev@users.noreply.github.com> Date: Sat, 14 May 2022 12:38:05 -0400 Subject: [PATCH] fix: ok statusCode can be 200..299 (#7919) --- packages/rest/__tests__/REST.test.ts | 15 +++++++++++++++ .../rest/src/lib/handlers/SequentialHandler.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/rest/__tests__/REST.test.ts b/packages/rest/__tests__/REST.test.ts index 18d2a46b241d..394282303c8e 100644 --- a/packages/rest/__tests__/REST.test.ts +++ b/packages/rest/__tests__/REST.test.ts @@ -253,6 +253,21 @@ test('postEcho', async () => { expect(await api.post('/postEcho', { body: { foo: 'bar' } })).toStrictEqual({ foo: 'bar' }); }); +test('201 status code', async () => { + mockPool + .intercept({ + path: genPath('/postNon200StatusCode'), + method: 'POST', + }) + .reply((t) => ({ + data: t.body!, + statusCode: 201, + responseOptions, + })); + + expect(await api.post('/postNon200StatusCode', { body: { foo: 'bar' } })).toStrictEqual({ foo: 'bar' }); +}); + test('Old Message Delete Edge-Case: Old message', async () => { mockPool .intercept({ diff --git a/packages/rest/src/lib/handlers/SequentialHandler.ts b/packages/rest/src/lib/handlers/SequentialHandler.ts index c8804fb2c394..90abd1915dc0 100644 --- a/packages/rest/src/lib/handlers/SequentialHandler.ts +++ b/packages/rest/src/lib/handlers/SequentialHandler.ts @@ -391,7 +391,7 @@ export class SequentialHandler implements IHandler { } } - if (status === 200) { + if (status >= 200 && status < 300) { return parseResponse(res); } else if (status === 429) { // A rate limit was hit - this may happen if the route isn't associated with an official bucket hash yet, or when first globally rate limited