question

coolcoder001 avatar image
coolcoder001 asked

Device Address is 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 simulatoralexa skills challengedevice address api
10 |5000

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

1 Answer

KAIYIN@AMAZON.COM avatar image
KAIYIN@AMAZON.COM answered

Did you use real echo Device or Test Simulator to test your Skill code? Because currently, test simulator doesn't support Device Address, you'd have to test it on a device. Also, in your logic (address.addressLine1 ===null&& address.stateOrRegion ===null), if address.addressLine1 equals null and address.stateOrRegions is not null, the else loop will still happen, you'd better change the logic to be (address.addressLine1 ===null || address.stateOrRegion ===null ) if that was your intention.

10 |5000

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