1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-10 22:00:05 +00:00

fix: extraResponseAttributes for WebJobExecutor + sasjs-tests

This commit is contained in:
Saad Jutt
2021-09-01 03:50:55 +05:00
parent 2a6e29b5b8
commit 867422f4cc
5 changed files with 68 additions and 40 deletions

View File

@@ -0,0 +1,22 @@
import { ExtraResponseAttributes } from '@sasjs/utils/types'
export async function appendExtraResponseAttributes(
response: any,
extraResponseAttributes: ExtraResponseAttributes[]
) {
let responseObject = {}
if (extraResponseAttributes?.length) {
const extraAttributes = extraResponseAttributes.reduce(
(map: any, obj: any) => ((map[obj] = response[obj]), map),
{}
)
responseObject = {
result: response.result,
...extraAttributes
}
} else responseObject = response.result
return responseObject
}