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')
}));
}
Last updated
Was this helpful?