[got] Allow primitive types in JSON body for POST requests (#27109)

This commit is contained in:
ikokostya
2018-07-06 14:24:26 -07:00
committed by Mohamed Hegazy
parent 2aad925037
commit 03eede6951
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -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'));
+1 -1
View File
@@ -100,7 +100,7 @@ declare namespace got {
}
interface GotJSONOptions extends GotOptions<string | null> {
body?: object;
body?: any;
form?: boolean;
json: true;
}