Address Input showing Object, Object in Email response. Instead of the actual address (Text)

Hello, Can anyone point me in the right direction, please. I have Address Input set up on a customer quote form. It picks up the address and places it into a database and shows the address correctly. I set up a sendGrid email to inform us of the customer request. However, the address shows up in the email as Object, Object. ( Address Input is set to a Address in Field Type) Is there a way to parse it across in the email correctly to show the actual request?
Thanks

Here is the sendGrid code I am using for the email response.

$w.onReady( function () {
//TODO: write your page related code here…

let address = $w(“#addressInput1”).value;
$w(“#addressInput1”)
;
});
import {sendEmail} from ‘backend/email’;
$w.onReady( function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = New Charter Request **from** ${$w("#input10").value};
const body = `New Charter Request: ${$w(“#input10”).value}
\rFirst Name: ${$w(“#input10”).value}

\rFrom: ${$w(“#addressInput1”).value}

\rEmail: ${$w(“#input11”).value}`;
const recipient = $w(“#input11”).value;

sendEmail(subject, body)
.then(response => console.log(response));
}
//import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;

I would suggest that you check Wix examples for using it with SendGrid and search this forum for previous posts about using SendGrid as your code has errors.

For starters, this bit at the top here is all happening before you have actually imported your backend email file and the page itself has loaded and is ready to go.

let address = $w(" #addressInput1 “).value; $w(” #addressInput1 ") ; });

If you use the AddressInput wrong in your code it will just return an object as shown in the value function for AddressInput itself.
https://www.wix.com/corvid/reference/$w.AddressInput.html#value

Description

The value of an address input is an object of type Address . The Address object’s data…

You are getting the error [object Object] because the $w(“#address”).value is a json object. Console log it to understand the values and use it accordingly in your email.

This is what the .value actually return

/*  {
 *    "formatted":"500 Terry A Francois Blvd, San Francisco, CA 94158, USA",
 *    "location": {
 *      "latitude": 37.7703718,
 *      "longitude": -122.38712479999998
 *    },
 *    "streetAddress": {
 *      "name":  "Terry A Francois Blvd",
 *      "number": "500"
 *    },
 *    "city": "SF",
 *    "subdivision": "CA",
 *    "country": "US",
 *    "postalCode": "94158"
 *  }
*/

So if you want to send the address city. You will need to do this.

let address = $w("#address").value;
let city = address.city; //use this in your email body like ${city}

Thanks Shan, Your advice has led me to the correct coding for my form to work as I needed.
Really appreciate the help :slight_smile: