Why is Axios Not Working for Mailchimp API Calls Despite No Network Issues?

This topic was automatically generated from Slack. You can find the original thread here.

Hi,
Last night I was able to use Axios to make a GET and POST call to the Mailchimp API. This morning the workflow is just spinning endlessly or giving some sort of an error. Any thoughts? I looked at the Mailchimp server status URL and it showed no network issues. This screenshot is all I see currently after clicking the Test button

image.png

After I refreshed the page, it returned a response this time. Now I will see if I can get the other step to complete that I was trying to get to finish.

I’m not sure

Does this mean anything to anyone at support?

DOMException [DataCloneError]: Symbol(PD:IMPORT_STEPS) could not be cloned.
    at new DOMException (node:internal/per_context/domexception:53:5)
    at finish (/var/task/launch_worker.js:701:25)
    at async MessagePort.messageHandler (/var/task/launch_worker.js:847:9)

Oh boy, I just figured out it was because I was using import axios from "axios" instead of
**import** { axios } **from** "@pipedream/platform";

I think I had used the generate AI code and I replaced that import axios from pipedream text without thinking about it

Could you share what the shape of the arguments to your axios call looked like?

Was it passing the $ first, then the request configuration?

Yes I believe so

Ah yup that’ll do it. The vanilla axios signature doesn’t accept the $

    await axios($, {
      method: "GET",
      url: url,
      headers: {
        Authorization: `Bearer ${this.mailchimp.$auth.oauth_access_token}`,
      },
    });

I wonder if you could build a polyfill for those instances where that’s happening, or maybe Pipedream can somehow detect if someone is doing that when using vanilla axios and trying to pass in the $ symbol?

Interesting suggestion, that would require us to overload the vanilla axios instance, which raises some other issues.

However, perhaps we can lint your code to check for vanilla axios usage + $ usage in the arguments.

I’ll pass this along!

Or at least maybe have a pop-up that says, “we notice you’re trying to use the $ symbol which is not supported in vanilla axios. A quick fix is to use the Pipedream platform version of axios.” and that would save people the headache of wondering what’s happening :slightly_smiling_face:

Yup that’s exactly what I was thinking too :slightly_smiling_face:

We have similar patterns for other common mistakes in code that are Pipedream specific