The vega-lite and vega documentations barely mention how to load data dynamically at run time. However, I couldn't find an example on how to make it work. It seems like you cannot use vegaEmbed for that, and you must use vega viewer. However for this to work you need to compile your spec first to vega.
Built with blockbuilder.org
https://cdn.jsdelivr.net/npm//vega@3.3.1
https://cdn.jsdelivr.net/npm//vega-lite@2.4.3