2
0

feat(engine): ️ Await for async code block

This commit is contained in:
Baptiste Arnaud
2022-03-25 16:25:37 +01:00
parent fb60dcf5ff
commit d756dff99e

View File

@ -48,7 +48,7 @@ export const executeLogic = async (
case LogicStepType.REDIRECT: case LogicStepType.REDIRECT:
return { nextEdgeId: executeRedirect(step, context) } return { nextEdgeId: executeRedirect(step, context) }
case LogicStepType.CODE: case LogicStepType.CODE:
return { nextEdgeId: executeCode(step, context) } return { nextEdgeId: await executeCode(step, context) }
case LogicStepType.TYPEBOT_LINK: case LogicStepType.TYPEBOT_LINK:
return await executeTypebotLink(step, context) return await executeTypebotLink(step, context)
} }
@ -121,12 +121,12 @@ const executeRedirect = (
return step.outgoingEdgeId return step.outgoingEdgeId
} }
const executeCode = ( const executeCode = async (
step: CodeStep, step: CodeStep,
{ typebot: { variables } }: LogicContext { typebot: { variables } }: LogicContext
) => { ) => {
if (!step.options.content) return if (!step.options.content) return
Function(parseVariables(variables)(step.options.content))() await Function(parseVariables(variables)(step.options.content))()
return step.outgoingEdgeId return step.outgoingEdgeId
} }