Closed maximedupre closed 2 years ago
error.data is of type TwitterApiErrorData, which should have an attribute errors of type (ErrorV1 | Error V2)[].
error.data
TwitterApiErrorData
errors
(ErrorV1 | Error V2)[]
However, in some cases it seems like it doesn't:
ApiResponseError: Request failed with code 401 at RequestHandlerHelper.createResponseError (/app/node_modules/twitter-api-v2/dist/client-mixins/request-handler.helper.js:103:16) at RequestHandlerHelper.onResponseEndHandler (/app/node_modules/twitter-api-v2/dist/client-mixins/request-handler.helper.js:252:25) at IncomingMessage.emit (node:events:525:35) at IncomingMessage.emit (node:domain:489:12) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { error: true, type: 'response', code: 401, headers: { 'content-type': 'application/problem+json', 'cache-control': 'no-cache, no-store, max-age=0', 'content-length': '99', 'x-response-time': '2', date: 'Tue, 30 Aug 2022 15:45:12 GMT', server: 'tsa_b', connection: 'close' }, rateLimit: undefined, data: { title: 'Unauthorized', type: 'about:blank', status: 401, detail: 'Unauthorized' } }
Should TwitterApiErrorData.errors be of type (ErrorV1 | Error V2)[] | undefined instead? Or is the error payload erroneous?
TwitterApiErrorData.errors
(ErrorV1 | Error V2)[] | undefined
Thanks :)
Hi, This can be a valid patch but this implies a breaking change. For now, consider accessing .errors getter on ApiResponseError that is already correctly typed :)
.errors
ApiResponseError
error.data
is of typeTwitterApiErrorData
, which should have an attributeerrors
of type(ErrorV1 | Error V2)[]
.However, in some cases it seems like it doesn't:
Should
TwitterApiErrorData.errors
be of type(ErrorV1 | Error V2)[] | undefined
instead? Or is the error payload erroneous?Thanks :)