How to Convert a Webflow Collection Item from _id to Text Name Using JS Code?

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

I need to convert the Webflow collection item using its _id to the actual text name. Can you suggest a JS Code to do that?

To convert a Webflow collection item using its _id to the actual text name, you can use the Webflow API to fetch the collection item details. Below is a Pipedream component that demonstrates how to achieve this using JavaScript: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { webflow: { type: "app", app: "webflow", }, siteId: { type: "string", label: "Site ID", }, collectionId: { type: "string", label: "Collection ID", }, itemId: { type: "string", label: "Item ID", }, }, async run({ steps, $ }) { const response = await axios($, { url: `https://api.webflow.com/collections/${this.collectionId}/items/${this.itemId}`, headers: { Authorization: `Bearer ${this.webflow.$auth.oauth_access_token}`, "accept-version": `1.0.0`, }, }); // Assuming the name field is stored under 'name' in the item data const itemName = response.name; return itemName; }, }); ### Explanation: 1. Props: The component defines three props (siteId, collectionId, and itemId) to accept the necessary IDs for the Webflow API request. 2. API Request: The axios request fetches the collection item details using the provided collectionId and itemId. 3. Extracting Name: The code assumes that the name of the item is stored in the name field of the response. Adjust this field based on your actual data structure. ### Steps to Use: 1. Search for the Webflow app from the step menu in Pipedream. 2. Select the custom code step and paste the above code. 3. Connect your Webflow account. 4. Provide the siteId, collectionId, and itemId as inputs. 5. Click Test to run the action and fetch the item name. If you need further assistance or have any questions, feel free to ask!

FYI you can continue asking Pi in the thread :sunglasses: