Using the iwa function will crash the whole thing if any of the posts of the instagram user we searched has no caption or no text (Example https://www.instagram.com/p/CmfebZmpg7y/ see OP hasnt written any text)
Getting the following error because el['node']['edge_media_to_caption']['edges'] returns an empty array:
Quick fix: Using optional chaining so it returns undefined for the posts with no text, without crashing the app.
text: el['node']['edge_media_to_caption']['edges'][0]?.['node']['text']
Using the iwa function will crash the whole thing if any of the posts of the instagram user we searched has no caption or no text (Example https://www.instagram.com/p/CmfebZmpg7y/ see OP hasnt written any text)
Getting the following error because el['node']['edge_media_to_caption']['edges'] returns an empty array:
Quick fix: Using optional chaining so it returns undefined for the posts with no text, without crashing the app. text: el['node']['edge_media_to_caption']['edges'][0]?.['node']['text']