Skip to content

Commit

Permalink
Add status code to the result of Kitsu.prototype.request.
Browse files Browse the repository at this point in the history
This allows looking for status codes like 206 to know it's a partial response.
  • Loading branch information
bglimepoint committed Dec 1, 2024
1 parent ba29c58 commit f158326
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/kitsu/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export default class Kitsu {
async request ({ body, method, params, type, url, headers, axiosOptions }) {
try {
method = method?.toUpperCase() || 'GET'
const { data, headers: responseHeaders } = await this.axios.request({
const { data, headers: responseHeaders, status: statusCode } = await this.axios.request({
method,
url,
data: [ 'GET', 'DELETE' ].includes(method)
Expand All @@ -524,7 +524,7 @@ export default class Kitsu {
...axiosOptions
})

return responseHeaders ? { ...deserialise(data), ...{ headers: responseHeaders } } : deserialise(data)
return { ...deserialise(data), statusCode, ...(responseHeaders ? { headers: responseHeaders } : {}) }
} catch (E) {
throw error(E)
}
Expand Down

0 comments on commit f158326

Please sign in to comment.