v9.0.0 - Removal of axios and Error Handling Changes
v9.0.0 - Removal of axios and Error Handling Changes
(1) In version 9.0.0, we have removed the axios dependency from the auto-generated clients, now utilizing the native fetch()
method. (Note that deprecated client will continue to use axios.)
We would like to express our gratitude to @tokuhirom for implementing this change to use the native fetch()
. Thank you very much for your contribution!!
(2) With the removal of axios, the structure of errors has been modified. This is a 💣breaking change💣, and users who are handling errors will need to modify your own code when using v9.0.0 of the line-bot-sdk-nodejs. (The error structure for deprecated client remains unchanged.) New error is HTTPFetchError
, which was HTTPError
. Thus clients(except for deprecated client) won't throw HTTPError
in v9.0.0.
Here is a brief overview of the differences. Retrieving the HTTP status code, headers, and error body from the Messaging API has become much simpler.
(For version < 9.0.0)
const client = new MessagingApiClient({
channelAccessToken: 'YOUR_CHANNEL_ACCESS_TOKEN',
});
client
.replyMessage({
replyToken: replyToken,
messages: [message]
})
.catch((err) => {
if (err instanceof HTTPError) {
// Displaying the HTTP status code, headers, and error body in sequence
console.error(err.originalError.response.status);
console.error(err.originalError.response.headers.get('x-line-request-id'));
console.error(err.originalError.response.data);
}
});
(For version >= 9.0.0)
const client = new MessagingApiClient({
channelAccessToken: 'YOUR_CHANNEL_ACCESS_TOKEN',
});
client
.replyMessage({
replyToken: replyToken,
messages: [message]
})
.catch((err) => {
if (err instanceof HTTPFetchError) { // 👈 client newly throws `HTTPFetchError` instead of `HTTPError`
// Displaying the HTTP status code, headers, and error body in sequence
console.error(err.status); // 👈 HTTP status code is in `HTTPFetchError`
console.error(err.headers.get('x-line-request-id')); // 👈 headers are in `HTTPFetchError`
console.error(err.body); // 👈 error body is in `HTTPFetchError`
}
});
(3) New ~WithHttpInfo
functions provide raw response
New ~WithHttpInfo
functions have been added. These functions return both the response itself and the parsed response body. This allows careful SDK users to obtain information such as (1) HTTP status codes and (2) HTTP response headers even on successful requests, which was not possible before. Please see the documentation (https://line.github.io/line-bot-sdk-nodejs/guide/client.html) for more details.
What's Changed
Dependency updates
- Update dependency @types/node to v20.11.21 by @renovate in #721
- Update dependency msw to v2.2.2 by @renovate in #722
- Update dependency @types/node to v20.11.22 by @renovate in #724
- Update dependency express to v4.18.3 by @renovate in #726
- Update dependency @types/node to v20.11.24 by @renovate in #725
- Update dependency typedoc to v0.25.10 by @renovate in #735
- Update dependency typedoc to v0.25.11 by @renovate in #738
- Update dependency @types/node to v20.11.25 by @renovate in #740
- Update dependency msw to v2.2.3 by @renovate in #741
Other Changes
- Bump ip from 1.1.8 to 1.1.9 in /examples/echo-bot-ts by @dependabot in #716
- Refactoring fetch-based code after PR, again #541, #582 by @tokuhirom in #723
- Implemented http-fetch's own exception. by @tokuhirom in #727
- api-test: use nodejs' http server instead of msw by @tokuhirom in #729
- Simplify the http-fetch.ts by @tokuhirom in #730
- Add WithHttpInfo method by @tokuhirom in #731
- add test cases for WithHttpInfo by @tokuhirom in #732
- Define api response type instead of array to access response and body easily by @Yang-33 in #733
- Enhance Documentation for Response and Error Handling in SDK by @Yang-33 in #734
- Compile example project by @Yang-33 in #736
- Refactoring Exception by @pengooseDev in #739
New Contributors
- @pengooseDev made their first contribution in #739
Full Changelog: v8.4.1...v9.0.0