Help with Axios request


I’m trying to run the following NodeJS step and getting an error message.

import { axios } from "@pipedream/platform";
import querystring from "querystring";

export default defineComponent({
  async run({ steps, $ }) {
    const { response } = await axios({
      url: "",
      method: "POST",
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      data: querystring.stringify({ 
        app_id: "id_here",
        api_key: "key_here",
        api_password: "password_here",
        cmd: "edit_lead",
        email: steps.get_record.$return_value.fields.buyer_email,
        last_name: "doe"

    return response;

The error I’m getting is:

Cannot read property 'headers' of undefined

I’m really confused because I’m passing the headers as part of the POST request.

Solved… I needed to add the $ object to axios:

await axios( $, {
1 Like