Sure, I can help you modify the code to work in a Cloud Convert Node.js instance. However, I need to clarify a few things: 1. Are you looking to run this code within a Pipedream workflow or outside of Pipedream? 2. If you’re looking to run this outside of Pipedream, please note that the axios function used in the code is a special version provided by Pipedream. If you’re running this code outside of Pipedream, you’ll need to install the axios package and use it instead. 3. You’ll also need to replace steps.trigger.event.webContentLink with the actual URL you want to convert. 4. Lastly, replace YOUR_CLOUDCONVERT_API_KEY with your actual CloudConvert API key. Please provide more details so I can assist you more accurately.
The code you’ve provided is already set up to run inside a Pipedream workflow. However, you need to make sure of a few things: 1. The steps.trigger.event.webContentLink is correctly providing the URL of the file you want to convert. This assumes that the trigger of your workflow is providing an event with a webContentLink property. If not, you’ll need to replace this with the actual URL of the file you want to convert. 2. Replace YOUR_CLOUDCONVERT_API_KEY with your actual CloudConvert API key. 3. The axios function used in the code is a special version provided by Pipedream. It’s already available in the Pipedream environment, so you don’t need to import it. 4. If you want to handle the response in a specific way, you can add your code in the // Handle the response section. 5. The return response.data; line will return the data from the CloudConvert API as the output of this step in the workflow. You can change this to handle the response as needed. If you encounter any issues or errors, please provide more details so I can assist you further.
ReferenceError
axios is not defined
DETAILS
at Object.run (file:///tmp/__pdg__/dist/code/32567e4f7b3669d0348a054dce185c7f4ee170b89fea765adebabadd77d4a96b/component.mjs:23:22)
at null.executeComponent (/var/task/launch_worker.js:267:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:764:28)
ReferenceError
axios is not defined
DETAILS
at Object.run (file:///tmp/__pdg__/dist/code/32567e4f7b3669d0348a054dce185c7f4ee170b89fea765adebabadd77d4a96b/component.mjs:23:22)
at null.executeComponent (/var/task/launch_worker.js:267:53)
at MessagePort.messageHandler (/var/task/launch_worker.js:764:28)
I see that you’re getting a ReferenceError saying axios is not defined. This error is occurring because the axios function is not being imported correctly in your Pipedream component. In Pipedream, you should import axios from the @pipedream/platform package, not the standard axios package. Here’s how you should do it: import { axios } from "@pipedream/platform"; Then, you can use axios in your run method like this: const response = await axios($, { method: "POST", url: `https://api.cloudconvert.com/v2/jobs`, headers: { Authorization: `Bearer YOUR_CLOUDCONVERT_API_KEY`, }, data: payload }); Please replace your axios usage in your code with this and try again. If you encounter any further issues, please let me know!