diff --git a/src/common.ts b/src/common.ts index 1f205464..7dd3eef8 100644 --- a/src/common.ts +++ b/src/common.ts @@ -35,6 +35,7 @@ export interface GaxiosResponse { config: GaxiosOptions; data: T; status: number; + statusText: string; headers: Headers; } diff --git a/src/gaxios.ts b/src/gaxios.ts index 950e0e71..c34751e0 100644 --- a/src/gaxios.ts +++ b/src/gaxios.ts @@ -183,6 +183,12 @@ export class Gaxios { headers[key] = value; }); - return {config: opts, data: data as T, headers, status: res.status}; + return { + config: opts, + data: data as T, + headers, + status: res.status, + statusText: res.statusText + }; } } diff --git a/test/test.getch.ts b/test/test.getch.ts index e5f57c4d..7bba30f1 100644 --- a/test/test.getch.ts +++ b/test/test.getch.ts @@ -219,6 +219,15 @@ describe('🎏 data handling', () => { scope.done(); assert.strictEqual(res.data, body); }); + + it('should return status text', async () => { + const body = {hello: '🌎'}; + const scope = nock(url).get('/').reply(200, body); + const res = await request({url}); + scope.done(); + assert.ok(res.data); + assert.strictEqual(res.statusText, 'OK'); + }); }); describe('🍂 defaults & instances', () => {