Laminar
  • Laminar
  • Platform
    • Overview
    • Getting Started
    • Advanced
      • Workflows
        • Global Workflow Object
        • HTTP Request Batching
        • Workflow Exit Points
        • Invoke Secondary Workflows
      • Configurations
      • Flows
        • Flow Types
          • HTTP Request
          • Data Transformations
        • Supported Languages
      • Managing Notifications
    • Best Practices
    • Keywords
      • lam.resolveThenExecute
      • lam.exit
      • lam.execute
      • lam.asyncExecute
      • lam.httpRequest
      • lam.httpRequests
  • API
    • Executing a Workflow
    • Creating a Configuration
    • Authentication
    • Changelog
  • External Links
    • Book a Demo
    • Sign In
Powered by GitBook
On this page
  • Example: Format User Names
  • Example: Filter and Enrich Orders

Was this helpful?

  1. Platform
  2. Advanced
  3. Flows
  4. Flow Types

Data Transformations

Learn about writing data transformations in Laminar Editor

Transformations allow you to modify data before or after making HTTP requests. They are written as JavaScript arrow functions and have access to specific libraries to help with data manipulation. The following imports are available:

* lodash as _
* date-fns: { format, parseISO }

Example: Format User Names

Let's start with a basic transformation that formats user names to uppercase:

// Transform user names to uppercase
(payload) => {
  const users = payload.step_2.response
  return users.map(user => ({
    ...user,
    name: user.name.toUpperCase()
  }));
}

Example: Filter and Enrich Orders

This example filters out canceled orders and adds formatted date strings:

// The `format` function is already available, no need to import
(payload) => {
  const orders = payload.input
  return orders
    .filter(order => order.status !== 'canceled')
    .map(order => ({
      ...order,
      formattedDate: format(new Date(order.createdAt), 'MMM dd, yyyy')
    }));
}
PreviousHTTP RequestNextSupported Languages

Last updated 1 month ago

Was this helpful?