Unexpected identifier Error in Raw Request Body

Hello,
I’m new to pipedream so following examples and I have run into an issue with posting an HTTP request where I reference the results of previous steps in the workflow. I keep getting “Unexpected identifier” executing the post. I have tried simplifying the values to make it work but it always throws that error.

The code is sending a slack message and the relevant part is:

"fields": [
  {
    "type": "mrkdwn",
     "text": "*buyer-listings-update*\nRequested: `{{steps.get_buyer_listings_update.$return_value[0].stats[0].metrics.requests}}`"
  },```

Any help or guidance much appreciated.

Hi @russell,

It looks like you’re trying to use a template string to reference the results of a previous step in your workflow. In Pipedream component code, you should use JavaScript string interpolation instead of the template string syntax you’re using.

Here’s the corrected code snippet:

"fields": [
  {
    "type": "mrkdwn",
    "text": `*buyer-listings-update*\nRequested: ${steps.get_buyer_listings_update.$return_value[0].stats[0].metrics.requests}`
  },
]

Make sure to replace the double curly braces {{ }} with ${ } and use backticks (`) instead of double quotes for the template string.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.

Thank you @pi, that did the trick.