How do I concatenate form data to a static URL using Zapier Code?

I’m working with Zapier Code and need help combining a form field value with a fixed URL string. My goal is to create a Google Maps link by adding an address from my form to the base maps URL. I want to eventually send a street view image via email instead of just a clickable link.

I’m not sure about the proper syntax for outputting the result. Here’s what I attempted:

let locationData = inputData.location;
var googleMapsUrl = "https://maps.google.com/maps?q=" + locationData;
output = googleMapsUrl;

Can someone provide a complete working code example? I’m new to this and need the full implementation.

Your code’s using assignment syntax when Zapier wants a return statement. Zapier Code steps need data returned in a specific format. Here’s the fix:

let locationData = inputData.location;
var googleMapsUrl = "https://maps.google.com/maps?q=" + locationData;

return {googleMapsUrl};

I’ve used Zapier Code for about two years and this got me at first too. The trick is using return and wrapping your output in an object. Also, if your location data has spaces or special characters, use encodeURIComponent(locationData) to avoid broken links. For street view, you’ll need Google’s Street View Static API - that requires an API key and different URL structure.

Your concatenation looks good, but you need to fix the output syntax for Zapier Code. Return an array with objects containing your data:

let locationData = inputData.location;
var googleMapsUrl = "https://maps.google.com/maps?q=" + locationData;

return [{googleMapsUrl: googleMapsUrl}];

I’ve used this same pattern in tons of automation workflows. The main thing is using return with an array instead of just assigning to output. For street view, you’ll want to switch to the Street View Static API endpoint later, but this gets you started. Just make sure your form field name matches what you’re calling in inputData.location.

you’re just missin the return syntax. try this:

let locationData = inputData.location;
var googleMapsUrl = "https://maps.google.com/maps?q=" + locationData;
return {url: googleMapsUrl};

zapier code needs that return statement - you can’t just use output like regular js. i’ve made that mistake too!