From 03eede695193d0d78291cee1262f7d59aa7fd4f9 Mon Sep 17 00:00:00 2001 From: ikokostya Date: Sat, 7 Jul 2018 00:24:26 +0300 Subject: [PATCH] [got] Allow primitive types in JSON body for POST requests (#27109) --- types/got/got-tests.ts | 16 ++++++++++++++++ types/got/index.d.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/types/got/got-tests.ts b/types/got/got-tests.ts index 1eb2d89aa8..a05812be8d 100644 --- a/types/got/got-tests.ts +++ b/types/got/got-tests.ts @@ -84,6 +84,22 @@ got.patch('todomvc.com', {hostname: 'todomvc'}).then(response => str = response. got.head('todomvc.com', {hostname: 'todomvc'}).then(response => str = response.body); got.delete('todomvc.com', {hostname: 'todomvc'}).then(response => str = response.body); +// Allow primitive types as JSON body. +{ + got.post('todomvc.com', { + json: true, + body: 1 + }); + got.post('todomvc.com', { + json: true, + body: null + }); + got.post('todomvc.com', { + json: true, + body: 'str' + }); +} + got.stream('todomvc.com').pipe(fs.createWriteStream('index.html')); fs.createReadStream('index.html').pipe(got.stream.get('todomvc.com')); diff --git a/types/got/index.d.ts b/types/got/index.d.ts index f786af118e..6b44aab339 100644 --- a/types/got/index.d.ts +++ b/types/got/index.d.ts @@ -100,7 +100,7 @@ declare namespace got { } interface GotJSONOptions extends GotOptions { - body?: object; + body?: any; form?: boolean; json: true; }