Web components are a set of web platform APIs that allow you to create new custom, reusable, encapsulated HTML tags to use in web pages and web apps. Custom components and widgets build on the Web Component standards, will work across modern browsers, and can be used with any JavaScript library or framework that works with HTML.
Fetching data in connectedCallback
If you wanted to fetch data using the client within a web component, you could do so in the connectedCallback lifecycle method. This method is called when the element is inserted into the DOM. So that you can await the data returned from Drupal, you must make the connectedCallback method async.
Using Lit
Using a library like Lit can reduce the boilerplate code required to create web components. The approach to fetching data will be similar. In the example below we are still using the client within the connectedCallback lifecycle method.