Deferred Promises in Function does not Defer Execution of Function

me, company name, SSQ ID, the company you are working for (Extraction/XTR/8North) and the tier assigned to your company in question #17.

|Y132~

|Y133~

|Y134~

|Y138~

|Y139~

|Y140~

|Y141~

|Y142~

|Y143~

that I have to replace each occurrence of a "|Y000~" with a URL link. That part of the code is working correctly. The problem is that I can't figure out how to use a promise to wait on the function (which includes deferral of multiple promises) to wait until the function finishes before moving on.