mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-04 19:20:05 +00:00
23 lines
552 B
TypeScript
23 lines
552 B
TypeScript
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
|
|
}
|