You'll need to expose some sort of API that your JavaScript can use to request data from your Craft install. 

There are two first-party options:

 1. Craft CMS has [GraphQL][1] support built into core. [The official docs][2] provides a fairly comprehensive guide to get up and running.

 2. If you prefer a RESTful API, the first-party [Element API plugin][3] provides a simple interface to configure your endpoints. The documentation for Element API can be found [on the plugin's GitHub page](https://github.com/craftcms/element-api).

Aside from that, if you happen to use Gatsby for your site there's also a first-party [Gatsby source plugin][4] for Craft.

Finally, when using Craft as a CMS for a headless app/site, it's also worth knowing about the [`headlessMode`][5], which "optimizes the system and control panel for headless CMS implementations".


  [1]: https://graphql.org/
  [2]: https://craftcms.com/docs/3.x/graphql.html
  [3]: https://plugins.craftcms.com/element-api?craft3
  [4]: https://github.com/craftcms/gatsby-source-craft
  [5]: https://craftcms.com/docs/3.x/config/general.html#headlessmode