File tree Expand file tree Collapse file tree 4 files changed +8
-8
lines changed
Expand file tree Collapse file tree 4 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ module.exports = function(config: JSONAtaExpression) {
1010 const result : any = { } ;
1111 try {
1212 let body = req . body ;
13- if ( typeof body === 'string' ) {
14- body = JSON . parse ( body ) ;
13+ if ( typeof body === 'string' || Buffer . isBuffer ( req . body ) ) {
14+ body = JSON . parse ( body . toString ( ) ) ;
1515 }
1616 result . body = expression . evaluate ( body ) ;
1717 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ module.exports = function(config: MustacheConfig) {
2828 const result : any = { } ;
2929 try {
3030 let body = req . body ;
31- if ( req . body && typeof req . body === 'string' ) {
32- body = JSON . parse ( req . body ) ;
31+ if ( req . body && ( typeof req . body === 'string' ) || Buffer . isBuffer ( req . body ) ) {
32+ body = JSON . parse ( req . body . toString ( ) ) ;
3333 }
3434 result . body = mustache . render ( template , body || { } ) ;
3535 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ module.exports = function(config: any) {
88 const result : any = { } ;
99 try {
1010 let body = req . body ;
11- if ( req . body && typeof req . body === 'string' ) {
12- body = JSON . parse ( req . body ) ;
11+ if ( req . body && typeof req . body === 'string' || Buffer . isBuffer ( req . body ) ) {
12+ body = JSON . parse ( req . body . toString ( ) ) ;
1313 }
1414 result . body = builder . buildObject ( body ) ;
1515 } catch ( e ) {
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ module.exports = function(config: JSONAtaExpression) {
1010 return new Promise < ResponseInterceptorResult > ( ( resolve , reject ) => {
1111 try {
1212 let bodyData = body ;
13- if ( typeof bodyData === 'string' ) {
14- bodyData = JSON . parse ( bodyData ) ;
13+ if ( typeof bodyData === 'string' || Buffer . isBuffer ( bodyData ) ) {
14+ bodyData = JSON . parse ( bodyData . toString ( ) ) ;
1515 }
1616 const result = expression . evaluate ( bodyData ) ;
1717 resolve ( { body : result } ) ;
You can’t perform that action at this time.
0 commit comments