1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 11:24:35 +00:00

fix: added http headers to /code api as well

This commit is contained in:
Saad Jutt
2022-02-18 07:25:48 +05:00
parent 2c4aa420b3
commit da899b90e2
2 changed files with 15 additions and 10 deletions

View File

@@ -30,15 +30,20 @@ export class CodeController {
const executeSASCode = async (req: any, { code }: ExecuteSASCodePayload) => {
try {
const { result } = (await new ExecutionController().executeProgram(
code,
getPreProgramVariables(req),
{ ...req.query, _debug: 131 },
undefined,
true
)) as ExecuteReturnRaw
const { result, httpHeaders } =
(await new ExecutionController().executeProgram(
code,
getPreProgramVariables(req),
{ ...req.query, _debug: 131 },
undefined,
true
)) as ExecuteReturnRaw
return result as string
Object.entries(httpHeaders).forEach(([key, value]) => {
req.res?.set(key, value)
})
return result
} catch (err: any) {
throw {
code: 400,

View File

@@ -85,7 +85,7 @@ const executeReturnRaw = async (
query
)) as ExecuteReturnRaw
Object.entries(httpHeaders ?? {}).forEach(([key, value]) => {
Object.entries(httpHeaders).forEach(([key, value]) => {
req.res?.set(key, value)
})
@@ -121,7 +121,7 @@ const executeReturnJson = async (
true
)) as ExecuteReturnJson
Object.entries(httpHeaders ?? {}).forEach(([key, value]) => {
Object.entries(httpHeaders).forEach(([key, value]) => {
req.res?.set(key, value)
})