Skip to content

Fix user_data.address extraction to handle array format#17

Open
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/address-extraction
Open

Fix user_data.address extraction to handle array format#17
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/address-extraction

Conversation

@ZLeventer
Copy link
Copy Markdown

Summary

Fixes #10.

user_data.address can be either a plain object or an array (e.g., address[0]). The current code assumes it is always an object, which causes incorrect field extraction when an array is provided.

This change checks the type of user_data.address at initialization and extracts address[0] when it is an array, falling back to the object as-is otherwise. All downstream consumers (getUserFirstName, getUserLastName, getUserCountryCode) work unchanged.

Changes

  • template.tpl: Replace const user_address = user_data.address || {}; with a two-step assignment that uses getType() (already imported) to detect arrays and unwrap the first element.

…elopers#10)

user_data.address can be either an object or an array (e.g.,
address[0]). Extract the first element when address is an array,
fall back to the object as-is otherwise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant