Hi @poplightDev
You might not be placing the javascript code in the right place. Look for theme.js or global.js under your Asset folder. Or you can also write the tag in your theme.liquid, under the layout folder, just place it before the so the code renders first before your script, or place defer in your script tag.
If your API has certain auth, you might not want to exposed it to the front end. Therefore, app is the better option.
If your API does not have any auth or password needed, you can try the above suggestion.