serverlessworkflow / sdk-typescript

Typescript SDK for Serverless Workflow
https://serverlessworkflow.io/
Apache License 2.0
62 stars 16 forks source link

Error while reading attributes of workflow #185

Closed raghumb closed 4 months ago

raghumb commented 4 months ago

What happened: Getting undefined error while printing attributes of workflow object.

What you expected to happen: workflow attributes should be fetched.

How to reproduce it: npm i @severlessworkflow/sdk-typescript import { Specification } from '@severlessworkflow/sdk-typescript';

json file contents: https://github.com/serverlessworkflow/sdk-typescript/blob/3.0.x/tests/examples/applicantrequest.json const expected = JSON.parse(fs.readFileSync('req.json', 'utf8')); const workflow: Specification.Workflow = Specification.Workflow.fromSource(expected); console.log(workflow.id)

Anything else we need to know?:

Environment: macOS Monterey

raghumb commented 4 months ago

I saw that I was parsing json object instead of string. Below code is correct way. Closing this. const expected =fs.readFileSync('req.json', 'utf8'); const workflow: Specification.Workflow = Specification.Workflow.fromSource(expected); console.log(workflow.id)