Skip to content

Commit cf077c8

Browse files
committed
Make sure response body is a string
1 parent 83f91e9 commit cf077c8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/response.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ class Response extends EventEmitter {
3333
if (this.writableEnded) throw new Error('write after end')
3434
this.writableEnded = true
3535
this.emit('finished')
36+
const body = this[AWS_RES_BODY]
37+
const bodyStr = body === 'string' ? body : JSON.stringify(body)
3638
const apiGatewayResult = {
3739
statusCode: this.statusCode,
3840
headers: this[AWS_RES_HEADERS],
39-
body: this[AWS_RES_BODY]
41+
body: bodyStr
4042
}
4143
this[ON_FINISHED](apiGatewayResult)
4244
}

0 commit comments

Comments
 (0)