question

coolcoder001 avatar image
coolcoder001 asked ·

Device address coming as undefined

if (address.addressLine1 === null && address.stateOrRegion === null) {
response = responseBuilder.speak(messages.NO_ADDRESS).getResponse();
} else {

const addrLine1 = address.addressLine1;
console.log(addrLine1)
//const ADDRESS_MESSAGE = `${messages.ADDRESS_AVAILABLE + address.addressLine1}, ${address.stateOrRegion}, ${address.postalCode}`;
response = responseBuilder.speak("Device ID is "+alexaDeviceId+" "+addrLine1).getResponse();
}
return response;

This is my piece of code.

I can see everytime the else block is being hit. So , that means , addressLine1 is not null.

But , everytime I am getting , addressLine1 as undefined. Can you please help ?

alexa skills kitalexaalexa dev daysalexa skills challengealexa prize
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jason@Amazon avatar image
Jason@Amazon answered ·

According to your if condition, you also hit the else block if the address.stateOrRegion is null as well. Try putting the console.log(addrLine1) before your if block is probably the better way to check that.

10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.