diff --git a/packages/axis-core/CHANGELOG.md b/packages/axis-core/CHANGELOG.md index 5d72f735..b71e3e04 100644 --- a/packages/axis-core/CHANGELOG.md +++ b/packages/axis-core/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - [BREAKING CHANGE] Deprecate Node.js v21 and below +### :syringe: Fixed + +- [#994](https://github.com/FantasticFiasco/axis-js/pull/994) Fix issue with `get` function not returning the correct response type. (contribution by [@spinda](https://github.com/spinda)) + ### :policeman: Security - Security vulnerability in transient dependency `http-cache-semantics` diff --git a/packages/axis-core/src/client.ts b/packages/axis-core/src/client.ts index 1e04ec4a..319909ec 100644 --- a/packages/axis-core/src/client.ts +++ b/packages/axis-core/src/client.ts @@ -9,7 +9,8 @@ import { Response } from './Response'; */ export const get = (connection: Connection, relativePath: string): Promise => { const url = connection.url + format(relativePath); - return clientProvider('GET', url, connection.username, connection.password, connection?.options?.agent).get(url); + const client = clientProvider('GET', url, connection.username, connection.password, connection?.options?.agent); + return client.get(url, { responseType: 'buffer' }); }; const format = (relativePath: string): string => { diff --git a/packages/axis-core/test/client.spec.ts b/packages/axis-core/test/client.spec.ts index 780d6bdc..a0f2b92d 100644 --- a/packages/axis-core/test/client.spec.ts +++ b/packages/axis-core/test/client.spec.ts @@ -24,6 +24,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); }); @@ -36,6 +37,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); }); @@ -48,6 +50,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); });